Skip to content

Commit 57b9f15

Browse files
anbaMs2ger
authored andcommitted
Allow alternative implementations for Chinese lunar calendar
1 parent efe0b18 commit 57b9f15

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-chinese.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const chinese = new Temporal.Calendar("chinese");
1717
const months2022TestData = [
1818
// TODO: Sources conflict over whether M01L and M12L exist in _any_ year.
1919
// Clarify this, and delete if appropriate. ICU has them, but may be wrong.
20+
//
21+
// - ICU4C and ICU4X both have M01L in Gregorian year 1651.
22+
// - ICU4C has M12L in Gregorian year 1889, but ICU4X doesn't.
23+
// - ICU4X has M12L in Gregorian year 1403, but ICU4C doesn't.
24+
2025
["M01", 1, 1],
2126
["M02", 2, 3],
2227
["M03", 3, 1],
@@ -31,13 +36,15 @@ const months2022TestData = [
3136
["M12", 12, 23],
3237
];
3338
for (const [nonLeapMonthCode, month, referenceISODay] of months2022TestData) {
39+
// Allow implementation-defined "epoch year" for the Chinese calendar.
40+
const year = new Temporal.PlainDate(2022, 3, 1).withCalendar(chinese).year;
3441
const leapMonthCode = nonLeapMonthCode + "L";
35-
const fields = { year: 2022, monthCode: leapMonthCode };
42+
const fields = { year, monthCode: leapMonthCode };
3643

3744
const result = chinese.yearMonthFromFields(fields, { overflow: "constrain" });
3845
TemporalHelpers.assertPlainYearMonth(
3946
result,
40-
2022, month, nonLeapMonthCode,
47+
year, month, nonLeapMonthCode,
4148
`Chinese intercalary month ${leapMonthCode} does not exist in year 2022 (overflow constrain)`,
4249
/* era = */ undefined, /* era year = */ undefined, referenceISODay
4350
);
@@ -49,9 +56,9 @@ for (const [nonLeapMonthCode, month, referenceISODay] of months2022TestData) {
4956
);
5057
}
5158

52-
// Years in which leap months exist according to ICU
59+
// Years in which leap months exist according to ICU4C/ICU4X.
5360
const leapMonthsTestData = [
54-
["M01L", 2148, 2, 20],
61+
["M01L", 1651, 2, 20],
5562
["M02L", 2023, 3, 22],
5663
["M03L", 1993, 4, 22],
5764
["M04L", 2020, 5, 23],
@@ -61,10 +68,11 @@ const leapMonthsTestData = [
6168
["M08L", 1995, 9, 25],
6269
["M09L", 2014, 10, 24],
6370
["M10L", 1984, 11, 23],
64-
["M11L", 2033, 12, 22],
65-
["M12L", 1889, 13, 21, 1890, 1],
71+
["M11L", 1517, 12, 23],
6672
];
67-
for (const [monthCode, year, month, referenceISODay, isoYear = year, isoMonth = month] of leapMonthsTestData) {
73+
for (const [monthCode, relatedYear, month, referenceISODay, isoYear = relatedYear, isoMonth = month] of leapMonthsTestData) {
74+
// Allow implementation-defined "epoch year" for the Chinese calendar.
75+
const year = new Temporal.PlainDate(relatedYear, 3, 1).withCalendar(chinese).year;
6876
const result = chinese.yearMonthFromFields({ year, monthCode });
6977
TemporalHelpers.assertPlainYearMonth(
7078
result,

0 commit comments

Comments
 (0)