From 20a70420a85aecab0bde1a58921197f423e401cc Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 15 Aug 2026 14:59:33 +0200 Subject: [PATCH] fix(web): keep timestamp date and time in the same locale (#7081) Co-authored-by: codex --- apps/web/src/timestampFormat.test.ts | 14 ++++++++++++++ apps/web/src/timestampFormat.ts | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/web/src/timestampFormat.test.ts b/apps/web/src/timestampFormat.test.ts index 1ac2b04a4bb9c1b20fe5617e441c7e39e405f623..f35c1c1fdbf855ea695240b973f60d951ebacfb8 100644 --- a/apps/web/src/timestampFormat.test.ts +++ b/apps/web/src/timestampFormat.test.ts @@ -176,6 +176,20 @@ describe("formatDayAwareTimestamp", () => { ); }); + it("uses the host locale for both the numeric date and wall-clock time", async () => { + vi.stubGlobal("window", { + desktopBridge: { getSystemLocale: () => "en-GB" }, + }); + vi.resetModules(); + + const { formatDayAwareTimestamp: formatWithHostLocale } = await import("./timestampFormat"); + const messageAt = iso(2026, 7, 12, 15, 44); + + expect(formatWithHostLocale(messageAt, "locale", now)).toBe("12/08 15:44"); + + vi.unstubAllGlobals(); + }); + it("returns an empty string for invalid input", () => { expect(formatDayAwareTimestamp("not-a-date", "12-hour", now)).toBe(""); }); diff --git a/apps/web/src/timestampFormat.ts b/apps/web/src/timestampFormat.ts index 5b57c5316e1d09603dfda7894dd27e7757553958..c1c30a544573f52996df3fb24890eeb148ab3bd8 100644 --- a/apps/web/src/timestampFormat.ts +++ b/apps/web/src/timestampFormat.ts @@ -127,11 +127,11 @@ export function formatShortTimestamp(isoDate: string, timestampFormat: Timestamp return getTimestampFormatter(timestampFormat, false).format(date); } -const numericDateFormatter = new Intl.DateTimeFormat(undefined, { +const numericDateFormatter = new Intl.DateTimeFormat(timestampLocale, { month: "numeric", day: "numeric", }); -const numericDateWithYearFormatter = new Intl.DateTimeFormat(undefined, { +const numericDateWithYearFormatter = new Intl.DateTimeFormat(timestampLocale, { month: "numeric", day: "numeric", year: "numeric", -- 2.54.0