Skip to content

Commit 1ff911d

Browse files
committed
fix(web): keep timestamp tooltip dates in English
1 parent eee0557 commit 1ff911d

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎apps/web/src/timestampFormat.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ describe("formatShortTimestamp", () => {
5252
});
5353
});
5454

55+
describe("formatChatTimestampTooltip", () => {
56+
afterEach(() => {
57+
vi.restoreAllMocks();
58+
vi.resetModules();
59+
});
60+
61+
it.each(["de-DE", "it-IT"])("keeps the English date label in a %s runtime", async (locale) => {
62+
const DateTimeFormat = Intl.DateTimeFormat;
63+
vi.spyOn(Intl, "DateTimeFormat").mockImplementation(function (locales, options) {
64+
return new DateTimeFormat(locales ?? locale, options);
65+
});
66+
vi.resetModules();
67+
const { formatChatTimestampTooltip: format } = await import("./timestampFormat");
68+
const date = new Date(2026, 5, 4, 14, 4).toISOString();
69+
70+
expect(format(date, "24-hour")).toBe("14:04, 4th June 2026");
71+
});
72+
});
73+
5574
describe("formatExpiresInLabel", () => {
5675
beforeEach(() => {
5776
vi.useFakeTimers();

‎apps/web/src/timestampFormat.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function parseTimestampDate(isoDate: string): Date | null {
8181
// Deliberately not the host locale: the tooltip's ordinal suffix and
8282
// day-before-month order below are English, so a localized month alone would
8383
// read "4th Juni 2026". Localizing the whole label is a separate change.
84-
const monthNameFormatter = new Intl.DateTimeFormat(undefined, { month: "long" });
84+
const monthNameFormatter = new Intl.DateTimeFormat("en-US", { month: "long" });
8585

8686
function ordinalSuffix(day: number): string {
8787
const lastTwo = day % 100;

0 commit comments

Comments
 (0)