diff --git a/apps/web/__tests__/unit/clock-hours.test.ts b/apps/web/__tests__/unit/clock-hours.test.ts index 65bafa47b9e..f0503b037ae 100644 --- a/apps/web/__tests__/unit/clock-hours.test.ts +++ b/apps/web/__tests__/unit/clock-hours.test.ts @@ -69,6 +69,13 @@ describe("formatClockWithHundredths", () => { expect(formatClockWithHundredths(3600)).toBe("1:00:00.00"); expect(formatClockWithHundredths(3905.5)).toBe("1:05:05.50"); }); + + it("carries a rounded-up minute instead of printing :60.00", () => { + expect(formatClockWithHundredths(59.994)).toBe("00:59.99"); + expect(formatClockWithHundredths(59.996)).toBe("01:00.00"); + expect(formatClockWithHundredths(119.999)).toBe("02:00.00"); + expect(formatClockWithHundredths(3599.999)).toBe("1:00:00.00"); + }); }); describe("Slack previews", () => { diff --git a/apps/web/lib/player-time.ts b/apps/web/lib/player-time.ts index 2d1fe91147f..b7fdea2a6ef 100644 --- a/apps/web/lib/player-time.ts +++ b/apps/web/lib/player-time.ts @@ -27,7 +27,9 @@ export function formatClock(seconds: number): string { } export function formatClockWithHundredths(seconds: number): string { - const safe = Math.max(0, seconds); + // Round before splitting so 59.996 carries into the next minute instead of + // printing as 00:60.00. + const safe = Number(Math.max(0, seconds).toFixed(2)); const hours = Math.floor(safe / 3600); const minutes = Math.floor((safe - hours * 3600) / 60); const remainingSeconds = safe - hours * 3600 - minutes * 60;