| 37 | * @param totalSeconds - Elapsed time in seconds (may be fractional; truncated). |
| 38 | */ |
| 39 | export function formatTime(totalSeconds: number): string { |
| 40 | const total = Math.max(0, Math.floor(isFinite(totalSeconds) ? totalSeconds : 0)); |
| 41 | const hours = Math.floor(total / 3600); |
| 42 | const minutes = Math.floor((total % 3600) / 60); |
| 43 | const secs = total % 60; |
| 44 | return [hours, minutes, secs].map((p) => String(p).padStart(2, '0')).join(':'); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Format a transmission progress value (0–100) as a percentage string like "42%". |