@@ -17,6 +17,11 @@ const chinese = new Temporal.Calendar("chinese");
17
17
const months2022TestData = [
18
18
// TODO: Sources conflict over whether M01L and M12L exist in _any_ year.
19
19
// 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
+
20
25
[ "M01" , 1 , 1 ] ,
21
26
[ "M02" , 2 , 3 ] ,
22
27
[ "M03" , 3 , 1 ] ,
@@ -31,13 +36,15 @@ const months2022TestData = [
31
36
[ "M12" , 12 , 23 ] ,
32
37
] ;
33
38
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 ;
34
41
const leapMonthCode = nonLeapMonthCode + "L" ;
35
- const fields = { year : 2022 , monthCode : leapMonthCode } ;
42
+ const fields = { year, monthCode : leapMonthCode } ;
36
43
37
44
const result = chinese . yearMonthFromFields ( fields , { overflow : "constrain" } ) ;
38
45
TemporalHelpers . assertPlainYearMonth (
39
46
result ,
40
- 2022 , month , nonLeapMonthCode ,
47
+ year , month , nonLeapMonthCode ,
41
48
`Chinese intercalary month ${ leapMonthCode } does not exist in year 2022 (overflow constrain)` ,
42
49
/* era = */ undefined , /* era year = */ undefined , referenceISODay
43
50
) ;
@@ -49,9 +56,9 @@ for (const [nonLeapMonthCode, month, referenceISODay] of months2022TestData) {
49
56
) ;
50
57
}
51
58
52
- // Years in which leap months exist according to ICU
59
+ // Years in which leap months exist according to ICU4C/ICU4X.
53
60
const leapMonthsTestData = [
54
- [ "M01L" , 2148 , 2 , 20 ] ,
61
+ [ "M01L" , 1651 , 2 , 20 ] ,
55
62
[ "M02L" , 2023 , 3 , 22 ] ,
56
63
[ "M03L" , 1993 , 4 , 22 ] ,
57
64
[ "M04L" , 2020 , 5 , 23 ] ,
@@ -61,10 +68,11 @@ const leapMonthsTestData = [
61
68
[ "M08L" , 1995 , 9 , 25 ] ,
62
69
[ "M09L" , 2014 , 10 , 24 ] ,
63
70
[ "M10L" , 1984 , 11 , 23 ] ,
64
- [ "M11L" , 2033 , 12 , 22 ] ,
65
- [ "M12L" , 1889 , 13 , 21 , 1890 , 1 ] ,
71
+ [ "M11L" , 1517 , 12 , 23 ] ,
66
72
] ;
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 ;
68
76
const result = chinese . yearMonthFromFields ( { year, monthCode } ) ;
69
77
TemporalHelpers . assertPlainYearMonth (
70
78
result ,
0 commit comments