Fix floats in ms time diff display util

This commit is contained in:
Vortrex
2021-04-20 21:35:05 -05:00
parent f9bc446e5d
commit 8f15a0bc25

View File

@@ -1008,7 +1008,7 @@ async function waitUntil(condition) {
clearInterval(interval); clearInterval(interval);
resolve(); resolve();
}, 1) }, 1);
}); });
} }
@@ -1296,20 +1296,20 @@ function getCurrentUnixTimestamp() {
// =========================================================================== // ===========================================================================
function msToTime(duration) { function msToTime(duration) {
let milliseconds = toInteger((duration % 1000) / 100); let milliseconds = Math.floor(toInteger((duration % 1000) / 100));
let seconds = toInteger((duration / 1000) % 60); let seconds = Math.floor(toInteger((duration / 1000) % 60));
let minutes = toInteger((duration / (1000 * 60)) % 60); let minutes = Math.floor(toInteger((duration / (1000 * 60)) % 60));
let hours = toInteger((duration / (1000 * 60 * 60)) % 24); let hours = Math.floor(toInteger((duration / (1000 * 60 * 60)) % 24));
let days = toInteger((duration / (1000 * 60 * 60 * 24)) % 365); let days = Math.floor(toInteger((duration / (1000 * 60 * 60 * 24)) % 365));
hours = (hours < 10) ? "0" + hours : hours; //hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes; //minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds; //seconds = (seconds < 10) ? "0" + seconds : seconds;
if (days !== 0) { if (days !== 0) {
return `${days} days ${hours}:${minutes}:${seconds}`; return `${days} days, ${hours} hours, ${minutes} minutes`;
} else { } else {
return `${hours}:${minutes}:${seconds}`; return `${hours} hours, ${minutes} minutes`;
} }
} }