From 42cc822aa29fab8d27ba28edb3f0970e21674d97 Mon Sep 17 00:00:00 2001 From: Paddy <89168564+patrickballard@users.noreply.github.com> Date: Thu, 5 Nov 2026 19:25:19 +0000 Subject: [PATCH] fix(web): carry a rounded-up minute in the editor's hundredths clock formatClockWithHundredths rounded the seconds after splitting off the minutes, so 59.996 s printed as 00:60.00. Round to hundredths first so the carry reaches the minutes and hours. Fixes #3419 --- apps/web/__tests__/unit/clock-hours.test.ts | 7 +++++++ apps/web/lib/player-time.ts | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) 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;