Files
shumai/src/ui/components/viewers/utils.ts
T

17 lines
510 B
TypeScript
Raw Normal View History

2026-05-19 16:05:09 +08:00
export const formatTime = (seconds: number): string => {
if (isNaN(seconds)) return '00:00'
const date = new Date(seconds * 1000)
const hh = date.getUTCHours()
const mm = date.getUTCMinutes()
const ss = date.getUTCSeconds().toString().padStart(2, '0')
if (hh) {
return `${hh}:${mm.toString().padStart(2, '0')}:${ss}`
}
return `${mm}:${ss}`
}
export const formatFrame = (seconds: number, fps: number): number => {
if (isNaN(seconds) || !fps) return 0
return Math.floor(seconds * fps)
}