Bringing back 2 helpers
This commit is contained in:
parent
92e121b356
commit
c62e199ea7
2 changed files with 696 additions and 0 deletions
18
Helpers/Duration.js
Normal file
18
Helpers/Duration.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Use to display the time remaining on the Battery widget
|
||||
function formatVagueHumanReadableDuration(totalSeconds) {
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds - (hours * 3600)) / 60);
|
||||
const seconds = totalSeconds - (hours * 3600) - (minutes * 60);
|
||||
|
||||
var str = "";
|
||||
if (hours) {
|
||||
str += hours.toString() + "h";
|
||||
}
|
||||
if (minutes) {
|
||||
str += minutes.toString() + "m";
|
||||
}
|
||||
if (!hours && !minutes) {
|
||||
str += seconds.toString() + "s";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue