Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/web/src/timestampFormat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
});
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/timestampFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading