mirror of
https://github.com/koel/koel
synced 2024-12-20 17:43:36 +00:00
30 lines
525 B
JavaScript
30 lines
525 B
JavaScript
|
export default {
|
||
|
/**
|
||
|
* Convert a duration in seconds into H:i:s format.
|
||
|
* If H is 0, it will be ommited.
|
||
|
*/
|
||
|
secondsToHis(d) {
|
||
|
d = parseInt(d);
|
||
|
|
||
|
var s = d%60;
|
||
|
|
||
|
if (s < 10) {
|
||
|
s = '0' + s;
|
||
|
}
|
||
|
|
||
|
var i = Math.floor((d/60)%60);
|
||
|
|
||
|
if (i < 10) {
|
||
|
i = '0' + i;
|
||
|
}
|
||
|
|
||
|
var h = Math.floor(d/3600);
|
||
|
|
||
|
if (h < 10) {
|
||
|
h = '0' + h;
|
||
|
}
|
||
|
|
||
|
return (h === '00' ? '' : h + ':') + i + ':' + s;
|
||
|
},
|
||
|
};
|