Download packages/client/src/lib/format.ts from QSLY/ghp: direct link, hf CLI and curl.
- Browser
- Download file 647 Bytes
-
https://huggingface.co/spaces/QSLY/ghp/resolve/main/packages/client/src/lib/format.ts
- Command line
-
hf download hf://spaces/QSLY/ghp/packages/client/src/lib/format.ts
-
curl -L -o format.ts https://huggingface.co/spaces/QSLY/ghp/resolve/main/packages/client/src/lib/format.ts
647 Bytes
| /** Format seconds to mm:ss (for playback time display) */ | |
| export function formatTime(seconds: number): string { | |
| if (!isFinite(seconds) || seconds < 0) return '0:00' | |
| const m = Math.floor(seconds / 60) | |
| const s = Math.floor(seconds % 60) | |
| return `${m}:${s.toString().padStart(2, '0')}` | |
| } | |
| /** Format seconds to mm:ss, returns '--:--' for invalid/zero values (for track duration display) */ | |
| export function formatDuration(seconds: number): string { | |
| if (!seconds || !isFinite(seconds) || seconds <= 0) return '--:--' | |
| const m = Math.floor(seconds / 60) | |
| const s = Math.floor(seconds % 60) | |
| return `${m}:${s.toString().padStart(2, '0')}` | |
| } | |