mirror of https://github.com/tc39/test262.git
Allow alternative implementations for Chinese lunar calendar
This commit is contained in:
parent
efe0b1871f
commit
57b9f154a6
|
@ -17,6 +17,11 @@ const chinese = new Temporal.Calendar("chinese");
|
|||
const months2022TestData = [
|
||||
// TODO: Sources conflict over whether M01L and M12L exist in _any_ year.
|
||||
// Clarify this, and delete if appropriate. ICU has them, but may be wrong.
|
||||
//
|
||||
// - ICU4C and ICU4X both have M01L in Gregorian year 1651.
|
||||
// - ICU4C has M12L in Gregorian year 1889, but ICU4X doesn't.
|
||||
// - ICU4X has M12L in Gregorian year 1403, but ICU4C doesn't.
|
||||
|
||||
["M01", 1, 1],
|
||||
["M02", 2, 3],
|
||||
["M03", 3, 1],
|
||||
|
@ -31,13 +36,15 @@ const months2022TestData = [
|
|||
["M12", 12, 23],
|
||||
];
|
||||
for (const [nonLeapMonthCode, month, referenceISODay] of months2022TestData) {
|
||||
// Allow implementation-defined "epoch year" for the Chinese calendar.
|
||||
const year = new Temporal.PlainDate(2022, 3, 1).withCalendar(chinese).year;
|
||||
const leapMonthCode = nonLeapMonthCode + "L";
|
||||
const fields = { year: 2022, monthCode: leapMonthCode };
|
||||
const fields = { year, monthCode: leapMonthCode };
|
||||
|
||||
const result = chinese.yearMonthFromFields(fields, { overflow: "constrain" });
|
||||
TemporalHelpers.assertPlainYearMonth(
|
||||
result,
|
||||
2022, month, nonLeapMonthCode,
|
||||
year, month, nonLeapMonthCode,
|
||||
`Chinese intercalary month ${leapMonthCode} does not exist in year 2022 (overflow constrain)`,
|
||||
/* era = */ undefined, /* era year = */ undefined, referenceISODay
|
||||
);
|
||||
|
@ -49,9 +56,9 @@ for (const [nonLeapMonthCode, month, referenceISODay] of months2022TestData) {
|
|||
);
|
||||
}
|
||||
|
||||
// Years in which leap months exist according to ICU
|
||||
// Years in which leap months exist according to ICU4C/ICU4X.
|
||||
const leapMonthsTestData = [
|
||||
["M01L", 2148, 2, 20],
|
||||
["M01L", 1651, 2, 20],
|
||||
["M02L", 2023, 3, 22],
|
||||
["M03L", 1993, 4, 22],
|
||||
["M04L", 2020, 5, 23],
|
||||
|
@ -61,10 +68,11 @@ const leapMonthsTestData = [
|
|||
["M08L", 1995, 9, 25],
|
||||
["M09L", 2014, 10, 24],
|
||||
["M10L", 1984, 11, 23],
|
||||
["M11L", 2033, 12, 22],
|
||||
["M12L", 1889, 13, 21, 1890, 1],
|
||||
["M11L", 1517, 12, 23],
|
||||
];
|
||||
for (const [monthCode, year, month, referenceISODay, isoYear = year, isoMonth = month] of leapMonthsTestData) {
|
||||
for (const [monthCode, relatedYear, month, referenceISODay, isoYear = relatedYear, isoMonth = month] of leapMonthsTestData) {
|
||||
// Allow implementation-defined "epoch year" for the Chinese calendar.
|
||||
const year = new Temporal.PlainDate(relatedYear, 3, 1).withCalendar(chinese).year;
|
||||
const result = chinese.yearMonthFromFields({ year, monthCode });
|
||||
TemporalHelpers.assertPlainYearMonth(
|
||||
result,
|
||||
|
|
Loading…
Reference in New Issue