authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-08-15 14:59:33+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-08-15 14:59:33+02:00
log20a70420a85aecab0bde1a58921197f423e401cc
tree2a06491e32c52c8a7ee699b36cb79244a3d95dce
parentec141c125726ae70f31f392e780afa8de446fdc4
signature Signed by PGP key B5690EEEBB952194

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

Co-authored-by: codex <codex@users.noreply.github.com>

2 files changed, 16 insertions(+), 2 deletions(-)

apps/web/src/timestampFormat.test.ts+14
......@@ -176,6 +176,20 @@ describe("formatDayAwareTimestamp", () => {
176176 );
177177 });
178178
179 it("uses the host locale for both the numeric date and wall-clock time", async () => {
180 vi.stubGlobal("window", {
181 desktopBridge: { getSystemLocale: () => "en-GB" },
182 });
183 vi.resetModules();
184
185 const { formatDayAwareTimestamp: formatWithHostLocale } = await import("./timestampFormat");
186 const messageAt = iso(2026, 7, 12, 15, 44);
187
188 expect(formatWithHostLocale(messageAt, "locale", now)).toBe("12/08 15:44");
189
190 vi.unstubAllGlobals();
191 });
192
179193 it("returns an empty string for invalid input", () => {
180194 expect(formatDayAwareTimestamp("not-a-date", "12-hour", now)).toBe("");
181195 });
apps/web/src/timestampFormat.ts+2-2
......@@ -127,11 +127,11 @@ export function formatShortTimestamp(isoDate: string, timestampFormat: Timestamp
127127 return getTimestampFormatter(timestampFormat, false).format(date);
128128}
129129
130const numericDateFormatter = new Intl.DateTimeFormat(undefined, {
130const numericDateFormatter = new Intl.DateTimeFormat(timestampLocale, {
131131 month: "numeric",
132132 day: "numeric",
133133});
134const numericDateWithYearFormatter = new Intl.DateTimeFormat(undefined, {
134const numericDateWithYearFormatter = new Intl.DateTimeFormat(timestampLocale, {
135135 month: "numeric",
136136 day: "numeric",
137137 year: "numeric",