Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(core): six date and time cases pin each CLDR version's words (#10264)

Christopher Chedeau28c2e3fe51b1
diff --git a/packages/core/src/DateInput/DateInputTouch.calendar.test.tsx b/packages/core/src/DateInput/DateInputTouch.calendar.test.tsx
index 6b77f5f525..e1c7223503 100644
--- a/packages/core/src/DateInput/DateInputTouch.calendar.test.tsx
+++ b/packages/core/src/DateInput/DateInputTouch.calendar.test.tsx
@@ -213,9 +213,12 @@ describe('the bottom sheet in a calendar', () => {
).not.toContain('Adar I 5785');
});
+ // English names the Ethiopic era "ERA1" in CLDR 47, which has no name for
+ // it, and "AM" in CLDR 48. Any other version expects "AM".
+ const era = process.versions.cldr?.startsWith('47.') ? 'ERA1' : 'AM';
it.each([
- ['a common year', '2026-09-08', 'Pagumen 2018 AM', 5, '2026-09-06'],
- ['a leap year', '2027-09-08', 'Pagumen 2019 AM', 6, '2027-09-06'],
+ ['a common year', '2026-09-08', `Pagumen 2018 ${era}`, 5, '2026-09-06'],
+ ['a leap year', '2027-09-08', `Pagumen 2019 ${era}`, 6, '2027-09-06'],
])(
'keeps six rows for the Ethiopic thirteenth month in %s',
(_name, value, label, length, first) => {
diff --git a/packages/core/src/utils/calendarDateParser.roundtrip.test.ts b/packages/core/src/utils/calendarDateParser.roundtrip.test.ts
index cc5d762c43..1eae90b53f 100644
--- a/packages/core/src/utils/calendarDateParser.roundtrip.test.ts
+++ b/packages/core/src/utils/calendarDateParser.roundtrip.test.ts
@@ -164,8 +164,14 @@ describe('committed text reads back as the same date (FR13)', () => {
formatCalendarDateHint({year, month: 1, day: 1}, 'am-ET', calendar);
expect(hint(2026, 'japanese')).toBe('1/1/8 R');
expect(hint(1990, 'japanese')).toBe('1/1/2 H');
- expect(hint(2026, 'roc')).toBe('1/1/115 ROC');
- expect(hint(1900, 'roc')).toBe('1/1/12 BROC');
+ // Amharic writes the Minguo eras as "R.O.C." and "Before R.O.C." in CLDR
+ // 47, and as "ROC" and "BROC" in CLDR 48. Any other version expects the
+ // CLDR 48 names.
+ const isCldr47 = process.versions.cldr?.startsWith('47.') ?? false;
+ expect(hint(2026, 'roc')).toBe(isCldr47 ? '1/1/115 R.O.C.' : '1/1/115 ROC');
+ expect(hint(1900, 'roc')).toBe(
+ isCldr47 ? '1/1/12 Before R.O.C.' : '1/1/12 BROC',
+ );
});
it('adds no era to a calendar whose era does not change', () => {
const day = {year: 2026, month: 1, day: 1};
diff --git a/packages/core/src/utils/calendarDateParser.test.ts b/packages/core/src/utils/calendarDateParser.test.ts
index 34f353db22..bfbfc4ba3b 100644
--- a/packages/core/src/utils/calendarDateParser.test.ts
+++ b/packages/core/src/utils/calendarDateParser.test.ts
@@ -43,6 +43,10 @@ afterAll(() => {
const TODAY = {year: 2026, month: 11, day: 2};
+// Some names differ between CLDR 47 and CLDR 48. Any other version expects
+// the CLDR 48 names, so new locale data fails here first.
+const isCldr47 = process.versions.cldr?.startsWith('47.') ?? false;
+
function parse(
locale: string,
calendar: CalendarSystem,
@@ -122,7 +126,18 @@ describe('reading dates written in the calendar (FR9)', () => {
// A weekday word that is also a month name.
expect(iso('fr-FR', 'gregory', 'mar. 3 nov. 2026')).toBe('2026-11-03');
expect(iso('it-IT', 'gregory', 'mar 3 mar 2026')).toBe('2026-03-03');
- expect(iso('vi-VN', 'gregory', 'Thứ 3, 3 thg 11, 2026')).toBe('2026-11-03');
+ // Vietnamese writes Tuesday as "Th 3" in CLDR 47 and as "Thứ 3" in CLDR
+ // 48. Both carry a digit that is not the day.
+ const tuesday = `${isCldr47 ? 'Th 3' : 'Thứ 3'}, 3 thg 11, 2026`;
+ expect(
+ formatCalendarDateText(
+ {year: 2026, month: 11, day: 3},
+ 'date_weekday',
+ 'vi-VN',
+ 'gregory',
+ ),
+ ).toBe(tuesday);
+ expect(iso('vi-VN', 'gregory', tuesday)).toBe('2026-11-03');
});
it('ignores case and Latin diacritics', () => {
@@ -213,7 +228,20 @@ describe('years of the calendar (FR10)', () => {
it('reads Ethiopic years in the AM era unless AA is typed', () => {
expect(iso('am-ET', 'ethiopic', '23/2/2019')).toBe('2026-11-02');
- expect(iso('am-ET', 'ethiopic', '1/1/7519 AA')).toBe('2026-09-11');
+ // English names the Amete Alem era "ERA0" in CLDR 47, which has no name
+ // for it, and "AA" in CLDR 48. A date before the AM era shows its era.
+ const ameteAlem = isCldr47 ? 'ERA0' : 'AA';
+ expect(
+ formatCalendarDateText(
+ {year: 1, month: 1, day: 1},
+ 'date',
+ 'en',
+ 'ethiopic',
+ ),
+ ).toBe(`Ter 8, 5493 ${ameteAlem}`);
+ expect(iso('am-ET', 'ethiopic', `1/1/7519 ${ameteAlem}`)).toBe(
+ '2026-09-11',
+ );
});
it('resolves a two-digit year within 80 years before and 19 after', () => {
diff --git a/packages/core/src/utils/timeFormat.test.ts b/packages/core/src/utils/timeFormat.test.ts
index dda7967b73..7440441b79 100644
--- a/packages/core/src/utils/timeFormat.test.ts
+++ b/packages/core/src/utils/timeFormat.test.ts
@@ -20,6 +20,10 @@ import {parseTimeInput, type ISOTimeString} from './timeParser';
const iso = (time: string) => time as ISOTimeString;
+// Some names differ between CLDR 47 and CLDR 48. Any other version expects
+// the CLDR 48 names, so new locale data fails here first.
+const isCldr47 = process.versions.cldr?.startsWith('47.') ?? false;
+
describe('resolveHourFormat', () => {
it.each([
['en', '12h'],
@@ -150,7 +154,10 @@ describe('parseLocaleTime', () => {
});
it('reads twelve-hour text whose pattern differs from the 24-hour one', () => {
- expect(parseLocaleTime('অপৰাহ্ন ২.৩০', 'as')).toBe('14:30');
+ // Assamese names the afternoon "PM" in CLDR 47 and "অপৰাহ্ন" in CLDR 48.
+ const asText = `${isCldr47 ? 'PM' : 'অপৰাহ্ন'} ২.৩০`;
+ expect(formatLocaleTime(iso('14:30'), 'as', '12h')).toBe(asText);
+ expect(parseLocaleTime(asText, 'as')).toBe('14:30');
expect(parseLocaleTime('ɣetrɔ ga 2:30', 'ee')).toBe('14:30');
expect(parseLocaleTime('Klock 2.30:05 PM', 'nds', true)).toBe('14:30:05');
expect(parseLocaleTime('2h30:05 PM', 'oc', true)).toBe('14:30:05');