mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 05:13:17 +00:00
Updated msToTime function
This commit is contained in:
parent
6ec4a068f9
commit
ca494df400
@ -1,17 +1,12 @@
|
|||||||
module.exports = function msToTime(duration, format) {
|
module.exports = function msToTime(duration) {
|
||||||
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)));
|
days = Math.floor((duration / (1000 * 60 * 60 * 24)));
|
||||||
|
|
||||||
days = (days < 10) ? "0" + days : days;
|
return +days > 0
|
||||||
hours = (hours < 10) ? "0" + hours : hours;
|
? `${days}:${+hours < 10 ? `0${hours}` : hours}:${+minutes < 10 ? `0${minutes}` : minutes}:${+seconds < 10 ? `0${seconds}` : seconds}`
|
||||||
minutes = (minutes < 10) ? "0" + minutes : minutes;
|
: +hours > 0
|
||||||
seconds = (seconds < 10) ? "0" + seconds : seconds;
|
? `${+hours < 10 ? `0${hours}` : hours}:${+minutes < 10 ? `0${minutes}` : minutes}:${+seconds < 10 ? `0${seconds}` : seconds}`
|
||||||
|
: `${+minutes < 10 ? `0${minutes}` : minutes}:${+seconds < 10 ? `0${seconds}` : seconds}`;
|
||||||
if (format === "hh:mm:ss") {
|
|
||||||
return `${hours}:${minutes}:${seconds}`;
|
|
||||||
} else if (format === "dd:hh:mm:ss") {
|
|
||||||
return `${days}:${hours}:${minutes}:${seconds}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user