| author | |
| committer | |
| log | 2c3353578098a9e55e203a72217abe993f97987e |
| tree | c09cb5958914db9ac7efc1d570c7aca71f7b403f |
| parent | bfba7781681eaa03eb465ce3d9a4ec07bf952b78 |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 20 insertions(+), 1 deletions(-)
apps/web/src/timestampFormat.test.ts+19| ... | @@ -52,6 +52,25 @@ describe("formatShortTimestamp", () => { | ... | @@ -52,6 +52,25 @@ describe("formatShortTimestamp", () => { |
| 52 | }); | 52 | }); |
| 53 | }); | 53 | }); |
| 54 | 54 | ||
| 55 | describe("formatChatTimestampTooltip", () => { | ||
| 56 | afterEach(() => { | ||
| 57 | vi.restoreAllMocks(); | ||
| 58 | vi.resetModules(); | ||
| 59 | }); | ||
| 60 | |||
| 61 | it.each(["de-DE", "it-IT"])("keeps the English date label in a %s runtime", async (locale) => { | ||
| 62 | const DateTimeFormat = Intl.DateTimeFormat; | ||
| 63 | vi.spyOn(Intl, "DateTimeFormat").mockImplementation(function (locales, options) { | ||
| 64 | return new DateTimeFormat(locales ?? locale, options); | ||
| 65 | }); | ||
| 66 | vi.resetModules(); | ||
| 67 | const { formatChatTimestampTooltip: format } = await import("./timestampFormat"); | ||
| 68 | const date = new Date(2026, 5, 4, 14, 4).toISOString(); | ||
| 69 | |||
| 70 | expect(format(date, "24-hour")).toBe("14:04, 4th June 2026"); | ||
| 71 | }); | ||
| 72 | }); | ||
| 73 | |||
| 55 | describe("formatExpiresInLabel", () => { | 74 | describe("formatExpiresInLabel", () => { |
| 56 | beforeEach(() => { | 75 | beforeEach(() => { |
| 57 | vi.useFakeTimers(); | 76 | vi.useFakeTimers(); |
apps/web/src/timestampFormat.ts+1-1| ... | @@ -81,7 +81,7 @@ export function parseTimestampDate(isoDate: string): Date | null { | ... | @@ -81,7 +81,7 @@ export function parseTimestampDate(isoDate: string): Date | null { |
| 81 | // Deliberately not the host locale: the tooltip's ordinal suffix and | 81 | // Deliberately not the host locale: the tooltip's ordinal suffix and |
| 82 | // day-before-month order below are English, so a localized month alone would | 82 | // day-before-month order below are English, so a localized month alone would |
| 83 | // read "4th Juni 2026". Localizing the whole label is a separate change. | 83 | // read "4th Juni 2026". Localizing the whole label is a separate change. |
| 84 | const monthNameFormatter = new Intl.DateTimeFormat(undefined, { month: "long" }); | 84 | const monthNameFormatter = new Intl.DateTimeFormat("en-US", { month: "long" }); |
| 85 | 85 | ||
| 86 | function ordinalSuffix(day: number): string { | 86 | function ordinalSuffix(day: number): string { |
| 87 | const lastTwo = day % 100; | 87 | const lastTwo = day % 100; |