fix(web): keep timestamp date and time in the same locale (#7081)
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
ec141c1257
commit
20a70420a8
2 files changed
+16
-2
No files matched your search
@@ -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("");
|
||||
});
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user