Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep timestamp date and time in the same locale #7081

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/7081/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 16 additions and 2 deletions.

x
0 of 2 viewed, 2 left
14 additions and 0 deletionsapps/web/src/timestampFormat.test.tsModified
View file
@@ -176,6 +176,20 @@
});
​
+ 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("");
});
2 additions and 2 deletionsapps/web/src/timestampFormat.tsModified
View file
@@ -127,11 +127,11 @@
return getTimestampFormatter(timestampFormat, false).format(date);
​
-const numericDateFormatter = new Intl.DateTimeFormat(undefined, {