ai-tube / src /lib /formatDuration.ts
jbilcke-hf's picture
jbilcke-hf HF staff
hide some features for the beta + improve player
f27679f
raw
history blame
338 Bytes
import { intervalToDuration } from 'date-fns'
export function formatDuration(seconds: number) {
const duration = intervalToDuration({ start: 0, end: seconds * 1000 })
const zeroPad = (num: any) => String(num).padStart(2, '0')
const formatted = `${zeroPad(duration.minutes)}:${zeroPad(duration.seconds)}`
return formatted
}