1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 09:53:17 +00:00

Merge pull request #3 from cwchristerw/time

Added days :D
This commit is contained in:
Matte 2020-02-10 21:26:23 +02:00 committed by GitHub
commit 531790edbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,17 @@
module.exports = function msToTime(duration, format) { module.exports = function msToTime(duration, format) {
if (format = "hh:mm:ss") {
var seconds = Math.floor((duration / 1000) % 60), var seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60), minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24); 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; 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 (format = "hh:mm:ss") {
return `${hours}:${minutes}:${seconds}`; return `${hours}:${minutes}:${seconds}`;
} else if (format = "dd:hh:mm") { } else if (format = "dd:hh:mm:ss") {
return `${days}:${hours}:${minutes}:${seconds}`;
} }
} }