@@ -12,12 +12,27 @@ features: [Temporal]
12
12
const tests = [
13
13
{
14
14
calendar : "islamic" ,
15
- inLeapYear : false ,
16
- daysInYear : 354 ,
17
- daysInMonth12 : 29 ,
18
- isoYear : 2023 ,
19
- isoMonth : 7 ,
20
- isoDay : 18
15
+ choices : [
16
+ // Approximations of the observational Islamic calendar as computed by ICU4C.
17
+ {
18
+ inLeapYear : false ,
19
+ daysInYear : 354 ,
20
+ daysInMonth12 : 29 ,
21
+ isoYear : 2023 ,
22
+ isoMonth : 7 ,
23
+ isoDay : 18
24
+ } ,
25
+
26
+ // Approximations of the observational Islamic calendar as computed by ICU4X.
27
+ {
28
+ inLeapYear : true ,
29
+ daysInYear : 355 ,
30
+ daysInMonth12 : 30 ,
31
+ isoYear : 2023 ,
32
+ isoMonth : 7 ,
33
+ isoDay : 19
34
+ }
35
+ ] ,
21
36
} ,
22
37
{
23
38
calendar : "islamic-umalqura" ,
@@ -48,12 +63,27 @@ const tests = [
48
63
} ,
49
64
{
50
65
calendar : "islamic-rgsa" ,
51
- inLeapYear : false ,
52
- daysInYear : 354 ,
53
- daysInMonth12 : 29 ,
54
- isoYear : 2023 ,
55
- isoMonth : 7 ,
56
- isoDay : 18
66
+ choices : [
67
+ // Approximations of the observational Islamic calendar as computed by ICU4C.
68
+ {
69
+ inLeapYear : false ,
70
+ daysInYear : 354 ,
71
+ daysInMonth12 : 29 ,
72
+ isoYear : 2023 ,
73
+ isoMonth : 7 ,
74
+ isoDay : 18
75
+ } ,
76
+
77
+ // Approximations of the observational Islamic calendar as computed by ICU4X.
78
+ {
79
+ inLeapYear : true ,
80
+ daysInYear : 355 ,
81
+ daysInMonth12 : 30 ,
82
+ isoYear : 2023 ,
83
+ isoMonth : 7 ,
84
+ isoDay : 19
85
+ }
86
+ ] ,
57
87
} ,
58
88
{
59
89
calendar : "islamic-tbla" ,
@@ -67,15 +97,29 @@ const tests = [
67
97
] ;
68
98
69
99
for ( const test of tests ) {
70
- const { calendar, inLeapYear , daysInYear , daysInMonth12 , isoYear , isoMonth , isoDay } = test ;
100
+ const { calendar, choices = [ test ] } = test ;
71
101
const year = 1445 ;
72
102
const date = Temporal . PlainDate . from ( { year, month : 1 , day : 1 , calendar } ) ;
73
103
const isoFields = date . getISOFields ( ) ;
74
- assert . sameValue ( date . calendarId , calendar ) ;
104
+ if ( calendar !== "islamicc" ) {
105
+ assert . sameValue ( date . calendarId , calendar ) ;
106
+ } else {
107
+ // TODO: Steps to canonicalize the calendar identifier are still missing.
108
+ // https://github.com/tc39/ecma402/issues/828
109
+ }
75
110
assert . sameValue ( date . year , year ) ;
76
111
assert . sameValue ( date . month , 1 ) ;
77
112
assert . sameValue ( date . monthCode , "M01" ) ;
78
113
assert . sameValue ( date . day , 1 ) ;
114
+
115
+ // Match the possible choice by comparing the ISO month and day values.
116
+ const choice = choices . find ( ( { isoMonth, isoDay } ) => {
117
+ return isoFields . isoMonth === isoMonth && isoFields . isoDay === isoDay ;
118
+ } ) ;
119
+ assert ( choice !== undefined , `No applicable choice found for calendar: ${ calendar } ` ) ;
120
+
121
+ const { inLeapYear, daysInYear, daysInMonth12, isoYear, isoMonth, isoDay } = choice ;
122
+
79
123
assert . sameValue ( date . inLeapYear , inLeapYear ) ;
80
124
assert . sameValue ( date . daysInYear , daysInYear ) ;
81
125
assert . sameValue ( date . monthsInYear , 12 ) ;
0 commit comments