diff options
Diffstat (limited to 'web/frontend/analytics-logic.ts')
| -rw-r--r-- | web/frontend/analytics-logic.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/web/frontend/analytics-logic.ts b/web/frontend/analytics-logic.ts index 7a53944..e8a1559 100644 --- a/web/frontend/analytics-logic.ts +++ b/web/frontend/analytics-logic.ts @@ -33,3 +33,11 @@ const roundStep = (value: number): number => { export const formatSpeed = (speed: number): string => `${speed.toFixed(1)}`; export const formatCotacol = (cotacol: number): string => (cotacol >= 100 ? `${Math.round(cotacol)}` : `${cotacol.toFixed(1)}`); + +export const formatHours = (hours: number): string => { + if (hours < 1) return `${Math.round(hours * 60)}m`; + const h = Math.floor(hours); + const m = Math.round((hours - h) * 60); + if (m === 0) return `${h}h`; + return `${h}h${String(m).padStart(2, "0")}`; +}; |
