Improve buildTimecode function

This commit is contained in:
Androz2091 2021-02-20 15:28:06 +01:00
parent 0a2c2c2de8
commit a984cd3f50

View file

@ -85,7 +85,7 @@ module.exports = class Util {
const required = ['days', 'hours', 'minutes', 'seconds']
const parsed = items.filter(x => required.includes(x)).map(m => data[m] > 0 ? data[m] : '')
const final = parsed.filter(x => !!x).join(':')
return final.length <= 3 ? `0:${final.length === 1 ? `0${final}` : final || 0}` : final
const final = parsed.filter(x => !!x).map((x) => x.toString().padStart(2, '0')).join(':')
return final.length <= 3 ? `0:${final.padStart(2, '0') || 0}` : final
}
}