Files
otunes/apps/web/lib/format-duration.ts
T

8 lines
332 B
TypeScript

/** Formats seconds as `m:ss`, flooring fractional and negative input. */
export function formatDuration(seconds: number): string {
const total = Math.max(0, Math.floor(seconds))
const minutes = Math.floor(total / 60)
const remainingSeconds = total % 60
return `${minutes}:${remainingSeconds.toString().padStart(2, "0")}`
}