Download src/shared/duration.ts from ghuser1/pixai: direct link, hf CLI and curl.
- Browser
- Download file 455 Bytes
-
https://huggingface.co/spaces/ghuser1/pixai/resolve/main/src/shared/duration.ts
- Command line
-
hf download hf://spaces/ghuser1/pixai/src/shared/duration.ts
-
curl -L -o duration.ts https://huggingface.co/spaces/ghuser1/pixai/resolve/main/src/shared/duration.ts
455 Bytes
| export function elapsedMs(startedAtMs: number, nowMs: number = Date.now()): number { | |
| return Math.max(0, nowMs - startedAtMs) | |
| } | |
| export function formatDuration(ms: number): string { | |
| const safe = Math.max(0, ms) | |
| const totalSeconds = Math.floor(safe / 1000) | |
| if (totalSeconds < 60) { | |
| return `${totalSeconds}s` | |
| } | |
| const minutes = Math.floor(totalSeconds / 60) | |
| const seconds = totalSeconds - minutes * 60 | |
| return `${minutes}m ${seconds}s` | |
| } | |