1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 02:00:20 +00:00

Update msToTime.js

This commit is contained in:
MatteZ02 2020-02-10 21:36:12 +02:00
parent 531790edbe
commit 0829af0d3a

View File

@ -1,17 +1,18 @@
module.exports = function msToTime(duration, format) {
var seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
days = Math.floor((duration / (1000 * 60 * 60 * 24)) % 24);
var seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
days = Math.floor((duration / (1000 * 60 * 60 * 24)) % 24);
days = (days < 10) ? "0" + days : days;
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
days = (days < 10) ? "0" + days : days;
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
if (format = "hh:mm:ss") {
if (format === "hh:mm:ss") {
console.log(format)
return `${hours}:${minutes}:${seconds}`;
} else if (format = "dd:hh:mm:ss") {
} else if (format === "dd:hh:mm:ss") {
return `${days}:${hours}:${minutes}:${seconds}`;
}
}