| 1 | export function formatGoalWorkTime(durationMs: number | undefined): string { |
| 2 | if (!Number.isFinite(durationMs) || (durationMs ?? 0) <= 0) return "0s"; |
| 3 | const totalSeconds = Math.max(1, Math.round((durationMs ?? 0) / 1000)); |
| 4 | if (totalSeconds < 60) return `${totalSeconds}s`; |
| 5 | const totalMinutes = Math.round(totalSeconds / 60); |
| 6 | if (totalMinutes < 60) return `${totalMinutes}m`; |
| 7 | const hours = Math.floor(totalMinutes / 60); |
| 8 | const minutes = totalMinutes % 60; |
| 9 | return minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`; |
| 10 | } |
| 11 |