mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 00:59:28 +01:00
14 lines
346 B
TypeScript
14 lines
346 B
TypeScript
function formatDuration(seconds: number): string {
|
|
const s = Math.floor(seconds) % 60
|
|
const m = Math.floor(seconds / 60) % 60
|
|
const h = Math.floor(seconds / 60 / 60)
|
|
|
|
let time = `${m.toString().padStart(1, '0')}:${s.toString().padStart(2, '0')}`
|
|
if (h > 0) {
|
|
time = `${h}:${time}`
|
|
}
|
|
return time
|
|
}
|
|
|
|
export default formatDuration
|