fix(web): keep timestamp tooltip dates in English (#10256)
This commit is contained in:
1 parent
bfba778168
commit
2c33535780
2 files changed
+20
-1
No files matched your search
@@ -52,6 +52,25 @@ describe("formatShortTimestamp", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatChatTimestampTooltip", () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it.each(["de-DE", "it-IT"])("keeps the English date label in a %s runtime", async (locale) => {
|
||||
const DateTimeFormat = Intl.DateTimeFormat;
|
||||
vi.spyOn(Intl, "DateTimeFormat").mockImplementation(function (locales, options) {
|
||||
return new DateTimeFormat(locales ?? locale, options);
|
||||
});
|
||||
vi.resetModules();
|
||||
const { formatChatTimestampTooltip: format } = await import("./timestampFormat");
|
||||
const date = new Date(2026, 5, 4, 14, 4).toISOString();
|
||||
|
||||
expect(format(date, "24-hour")).toBe("14:04, 4th June 2026");
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatExpiresInLabel", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
@@ -81,7 +81,7 @@ export function parseTimestampDate(isoDate: string): Date | null {
|
||||
// Deliberately not the host locale: the tooltip's ordinal suffix and
|
||||
// day-before-month order below are English, so a localized month alone would
|
||||
// read "4th Juni 2026". Localizing the whole label is a separate change.
|
||||
const monthNameFormatter = new Intl.DateTimeFormat(undefined, { month: "long" });
|
||||
const monthNameFormatter = new Intl.DateTimeFormat("en-US", { month: "long" });
|
||||
|
||||
function ordinalSuffix(day: number): string {
|
||||
const lastTwo = day % 100;
|
||||
|
||||
Reference in new issue
Block a user