14 lines
433 B
JavaScript
14 lines
433 B
JavaScript
/** @param {number} seconds */
|
|
export function formatClipTime(seconds) {
|
|
if (!Number.isFinite(seconds) || seconds < 0) {
|
|
return '0:00';
|
|
}
|
|
const total = Math.floor(seconds);
|
|
const s = total % 60;
|
|
const m = Math.floor(total / 60) % 60;
|
|
const h = Math.floor(total / 3600);
|
|
if (h > 0) {
|
|
return `${h}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`;
|
|
}
|
|
return `${m}:${String(s).padStart(2, '0')}`;
|
|
}
|