LibJS: Ensure relevant extension keys are included in ICU locale data

This is a normative change in the ECMA-402 spec. See:
7508197

In our implementation, we don't have the affected AOs directly, as we
delegate to ICU. So instead, we must ensure we provide ICU a locale with
the relevant extension keys present.
This commit is contained in:
Timothy Flynn 2025-03-17 16:24:09 -04:00 committed by Tim Flynn
commit 00d00b84d3
Notes: github-actions[bot] 2025-03-18 15:48:22 +00:00
17 changed files with 82 additions and 67 deletions

View file

@ -652,17 +652,17 @@ describe("Temporal objects", () => {
test("Temporal.PlainDate", () => {
const plainDate = new Temporal.PlainDate(1989, 1, 23);
expect(formatter.format(plainDate)).toBe("1/23/1989");
expect(formatter.format(plainDate)).toBe("1989-01-23");
});
test("Temporal.PlainYearMonth", () => {
const plainYearMonth = new Temporal.PlainYearMonth(1989, 1);
expect(formatter.format(plainYearMonth)).toBe("1/1989");
expect(formatter.format(plainYearMonth)).toBe("1989-01");
});
test("Temporal.PlainMonthDay", () => {
const plainMonthDay = new Temporal.PlainMonthDay(1, 23);
expect(formatter.format(plainMonthDay)).toBe("1/23");
expect(formatter.format(plainMonthDay)).toBe("01-23");
});
test("Temporal.PlainTime", () => {
@ -672,6 +672,6 @@ describe("Temporal objects", () => {
test("Temporal.Instant", () => {
const instant = new Temporal.Instant(1732740069000000000n);
expect(formatter.format(instant)).toBe("11/27/2024, 8:41:09 PM");
expect(formatter.format(instant)).toBe("2024-11-27, 8:41:09 PM");
});
});

View file

@ -322,19 +322,19 @@ describe("Temporal objects", () => {
test("Temporal.PlainDate", () => {
const plainDate1 = new Temporal.PlainDate(1989, 1, 23);
const plainDate2 = new Temporal.PlainDate(2024, 11, 27);
expect(formatter.formatRange(plainDate1, plainDate2)).toBe("1/23/1989 11/27/2024");
expect(formatter.formatRange(plainDate1, plainDate2)).toBe("1989-01-23 2024-11-27");
});
test("Temporal.PlainYearMonth", () => {
const plainYearMonth1 = new Temporal.PlainYearMonth(1989, 1);
const plainYearMonth2 = new Temporal.PlainYearMonth(2024, 11);
expect(formatter.formatRange(plainYearMonth1, plainYearMonth2)).toBe("1/1989 11/2024");
expect(formatter.formatRange(plainYearMonth1, plainYearMonth2)).toBe("1989-01 2024-11");
});
test("Temporal.PlainMonthDay", () => {
const plainMonthDay1 = new Temporal.PlainMonthDay(1, 23);
const plainMonthDay2 = new Temporal.PlainMonthDay(11, 27);
expect(formatter.formatRange(plainMonthDay1, plainMonthDay2)).toBe("1/23 11/27");
expect(formatter.formatRange(plainMonthDay1, plainMonthDay2)).toBe("01-23 11-27");
});
test("Temporal.PlainTime", () => {
@ -347,7 +347,7 @@ describe("Temporal objects", () => {
const instant1 = new Temporal.Instant(601546251000000000n);
const instant2 = new Temporal.Instant(1732740069000000000n);
expect(formatter.formatRange(instant1, instant2)).toBe(
"1/23/1989, 8:10:51 AM 11/27/2024, 8:41:09 PM"
"1989-01-23, 8:10:51 AM 2024-11-27, 8:41:09 PM"
);
});
});

View file

@ -736,17 +736,17 @@ describe("Temporal objects", () => {
const plainDate1 = new Temporal.PlainDate(1989, 1, 23);
const plainDate2 = new Temporal.PlainDate(2024, 11, 27);
expect(formatter.formatRangeToParts(plainDate1, plainDate2)).toEqual([
{ type: "month", value: "1", source: "startRange" },
{ type: "literal", value: "/", source: "startRange" },
{ type: "day", value: "23", source: "startRange" },
{ type: "literal", value: "/", source: "startRange" },
{ type: "year", value: "1989", source: "startRange" },
{ type: "literal", value: "-", source: "startRange" },
{ type: "month", value: "01", source: "startRange" },
{ type: "literal", value: "-", source: "startRange" },
{ type: "day", value: "23", source: "startRange" },
{ type: "literal", value: " ", source: "shared" },
{ type: "month", value: "11", source: "endRange" },
{ type: "literal", value: "/", source: "endRange" },
{ type: "day", value: "27", source: "endRange" },
{ type: "literal", value: "/", source: "endRange" },
{ type: "year", value: "2024", source: "endRange" },
{ type: "literal", value: "-", source: "endRange" },
{ type: "month", value: "11", source: "endRange" },
{ type: "literal", value: "-", source: "endRange" },
{ type: "day", value: "27", source: "endRange" },
]);
});
@ -754,13 +754,13 @@ describe("Temporal objects", () => {
const plainYearMonth1 = new Temporal.PlainYearMonth(1989, 1);
const plainYearMonth2 = new Temporal.PlainYearMonth(2024, 11);
expect(formatter.formatRangeToParts(plainYearMonth1, plainYearMonth2)).toEqual([
{ type: "month", value: "1", source: "startRange" },
{ type: "literal", value: "/", source: "startRange" },
{ type: "year", value: "1989", source: "startRange" },
{ type: "literal", value: "-", source: "startRange" },
{ type: "month", value: "01", source: "startRange" },
{ type: "literal", value: " ", source: "shared" },
{ type: "month", value: "11", source: "endRange" },
{ type: "literal", value: "/", source: "endRange" },
{ type: "year", value: "2024", source: "endRange" },
{ type: "literal", value: "-", source: "endRange" },
{ type: "month", value: "11", source: "endRange" },
]);
});
@ -768,12 +768,12 @@ describe("Temporal objects", () => {
const plainMonthDay1 = new Temporal.PlainMonthDay(1, 23);
const plainMonthDay2 = new Temporal.PlainMonthDay(11, 27);
expect(formatter.formatRangeToParts(plainMonthDay1, plainMonthDay2)).toEqual([
{ type: "month", value: "1", source: "startRange" },
{ type: "literal", value: "/", source: "startRange" },
{ type: "month", value: "01", source: "startRange" },
{ type: "literal", value: "-", source: "startRange" },
{ type: "day", value: "23", source: "startRange" },
{ type: "literal", value: " ", source: "shared" },
{ type: "month", value: "11", source: "endRange" },
{ type: "literal", value: "/", source: "endRange" },
{ type: "literal", value: "-", source: "endRange" },
{ type: "day", value: "27", source: "endRange" },
]);
});
@ -804,11 +804,11 @@ describe("Temporal objects", () => {
const instant1 = new Temporal.Instant(601546251000000000n);
const instant2 = new Temporal.Instant(1732740069000000000n);
expect(formatter.formatRangeToParts(instant1, instant2)).toEqual([
{ type: "month", value: "1", source: "startRange" },
{ type: "literal", value: "/", source: "startRange" },
{ type: "day", value: "23", source: "startRange" },
{ type: "literal", value: "/", source: "startRange" },
{ type: "year", value: "1989", source: "startRange" },
{ type: "literal", value: "-", source: "startRange" },
{ type: "month", value: "01", source: "startRange" },
{ type: "literal", value: "-", source: "startRange" },
{ type: "day", value: "23", source: "startRange" },
{ type: "literal", value: ", ", source: "startRange" },
{ type: "hour", value: "8", source: "startRange" },
{ type: "literal", value: ":", source: "startRange" },
@ -818,11 +818,11 @@ describe("Temporal objects", () => {
{ type: "literal", value: " ", source: "startRange" },
{ type: "dayPeriod", value: "AM", source: "startRange" },
{ type: "literal", value: " ", source: "shared" },
{ type: "month", value: "11", source: "endRange" },
{ type: "literal", value: "/", source: "endRange" },
{ type: "day", value: "27", source: "endRange" },
{ type: "literal", value: "/", source: "endRange" },
{ type: "year", value: "2024", source: "endRange" },
{ type: "literal", value: "-", source: "endRange" },
{ type: "month", value: "11", source: "endRange" },
{ type: "literal", value: "-", source: "endRange" },
{ type: "day", value: "27", source: "endRange" },
{ type: "literal", value: ", ", source: "endRange" },
{ type: "hour", value: "8", source: "endRange" },
{ type: "literal", value: ":", source: "endRange" },

View file

@ -350,28 +350,28 @@ describe("Temporal objects", () => {
test("Temporal.PlainDate", () => {
const plainDate = new Temporal.PlainDate(1989, 1, 23);
expect(formatter.formatToParts(plainDate)).toEqual([
{ type: "month", value: "1" },
{ type: "literal", value: "/" },
{ type: "day", value: "23" },
{ type: "literal", value: "/" },
{ type: "year", value: "1989" },
{ type: "literal", value: "-" },
{ type: "month", value: "01" },
{ type: "literal", value: "-" },
{ type: "day", value: "23" },
]);
});
test("Temporal.PlainYearMonth", () => {
const plainYearMonth = new Temporal.PlainYearMonth(1989, 1);
expect(formatter.formatToParts(plainYearMonth)).toEqual([
{ type: "month", value: "1" },
{ type: "literal", value: "/" },
{ type: "year", value: "1989" },
{ type: "literal", value: "-" },
{ type: "month", value: "01" },
]);
});
test("Temporal.PlainMonthDay", () => {
const plainMonthDay = new Temporal.PlainMonthDay(1, 23);
expect(formatter.formatToParts(plainMonthDay)).toEqual([
{ type: "month", value: "1" },
{ type: "literal", value: "/" },
{ type: "month", value: "01" },
{ type: "literal", value: "-" },
{ type: "day", value: "23" },
]);
});
@ -392,11 +392,11 @@ describe("Temporal objects", () => {
test("Temporal.Instant", () => {
const instant = new Temporal.Instant(1732740069000000000n);
expect(formatter.formatToParts(instant)).toEqual([
{ type: "month", value: "11" },
{ type: "literal", value: "/" },
{ type: "day", value: "27" },
{ type: "literal", value: "/" },
{ type: "year", value: "2024" },
{ type: "literal", value: "-" },
{ type: "month", value: "11" },
{ type: "literal", value: "-" },
{ type: "day", value: "27" },
{ type: "literal", value: ", " },
{ type: "hour", value: "8" },
{ type: "literal", value: ":" },

View file

@ -129,6 +129,11 @@ describe("second", () => {
runTest("second", "narrow", "auto", en, ar, pl);
});
test("numberingSystem set via locale options", () => {
const formatter = new Intl.RelativeTimeFormat("en", { numberingSystem: "arab" });
expect(formatter.format(1, "second")).toBe("in ١ second");
});
});
describe("minute", () => {