Do not show hours when duration is shorter #14

This commit is contained in:
Rafostar
2020-11-20 22:41:33 +01:00
parent 7ccd6ad424
commit c221f7cdb6
3 changed files with 17 additions and 9 deletions

View File

@@ -68,13 +68,18 @@ function inhibitForState(state, window)
debug(`set prevent suspend to: ${isInhibited}`);
}
function getFormatedTime(time)
function getFormattedTime(time, showHours)
{
let hours = ('0' + Math.floor(time / 3600)).slice(-2);
time -= hours * 3600;
let hours;
if(showHours || time >= 3600) {
hours = ('0' + Math.floor(time / 3600)).slice(-2);
time -= hours * 3600;
}
let minutes = ('0' + Math.floor(time / 60)).slice(-2);
time -= minutes * 60;
let seconds = ('0' + Math.floor(time)).slice(-2);
return `${hours}:${minutes}:${seconds}`;
let parsed = (hours) ? `${hours}:` : '';
return parsed + `${minutes}:${seconds}`;
}