Fix duration formatting (#91)

* Fix duration formatting

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2023-06-28 13:42:23 -04:00
1 parent a675811488
commit bdaaf17785
5 files changed
+48 -9

No files matched your search

+13 -2
View File
@@ -151,10 +151,21 @@
}
function getFormattedTime(length) {
const minutes = Math.floor(length / 60).toString();
const hours = Math.floor(length / 3600);
const minutes = Math.floor((length / 60) % 60);
const seconds = length % 60;
const secondsString = seconds < 10 ? `0${seconds}` : seconds.toString();
return minutes + ":" + secondsString;
const minutesString =
minutes < 10 && hours > 0 ? `0${minutes}` : minutes.toString();
let formattedTime = minutesString + ":" + secondsString;
if (hours > 0) {
formattedTime = hours.toString() + ":" + formattedTime;
}
return formattedTime;
}
function isVideoLive() {