Skip to content

Commit 1e86088

Browse files
anbaptomato
authored andcommitted
Allow different approximations in the observational Islamic calendar
The "islamic" calendar id refers to the observational Islamic calendar and different implementation may use different algorithms to approximate when the moon's crescent can be observed. Change the test data to allow the approximations used in ICU4X in addition to the ones used in ICU4C.
1 parent 0614bdb commit 1e86088

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed

test/staging/Intl402/Temporal/old/islamic-calendars.js

+44-9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,23 @@ features: [Temporal]
1212
const tests = [
1313
{
1414
calendar: "islamic",
15-
inLeapYear: false,
16-
daysInYear: 354,
17-
daysInMonth12: 29,
18-
isoDate: "2023-07-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+
isoDate: "2023-07-18",
22+
},
23+
24+
// Approximations of the observational Islamic calendar as computed by ICU4X.
25+
{
26+
inLeapYear: true,
27+
daysInYear: 355,
28+
daysInMonth12: 30,
29+
isoDate: "2023-07-19",
30+
}
31+
],
1932
},
2033
{
2134
calendar: "islamic-umalqura",
@@ -33,10 +46,23 @@ const tests = [
3346
},
3447
{
3548
calendar: "islamic-rgsa",
36-
inLeapYear: false,
37-
daysInYear: 354,
38-
daysInMonth12: 29,
39-
isoDate: "2023-07-18",
49+
choices: [
50+
// Approximations of the observational Islamic calendar as computed by ICU4C.
51+
{
52+
inLeapYear: false,
53+
daysInYear: 354,
54+
daysInMonth12: 29,
55+
isoDate: "2023-07-18",
56+
},
57+
58+
// Approximations of the observational Islamic calendar as computed by ICU4X.
59+
{
60+
inLeapYear: true,
61+
daysInYear: 355,
62+
daysInMonth12: 30,
63+
isoDate: "2023-07-19",
64+
}
65+
],
4066
},
4167
{
4268
calendar: "islamic-tbla",
@@ -48,14 +74,23 @@ const tests = [
4874
];
4975

5076
for (const test of tests) {
51-
const { calendar, inLeapYear, daysInYear, daysInMonth12, isoDate } = test;
77+
const { calendar, choices = [test] } = test;
5278
const year = 1445;
5379
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
5480
assert.sameValue(date.calendarId, calendar);
5581
assert.sameValue(date.year, year);
5682
assert.sameValue(date.month, 1);
5783
assert.sameValue(date.monthCode, "M01");
5884
assert.sameValue(date.day, 1);
85+
86+
// Match the possible choice by comparing the ISO date value.
87+
const choice = choices.find(({ isoDate }) => {
88+
return date.toString().startsWith(isoDate);
89+
});
90+
assert(choice !== undefined, `No applicable choice found for calendar: ${calendar}`);
91+
92+
const { inLeapYear, daysInYear, daysInMonth12, isoDate } = choice;
93+
5994
assert.sameValue(date.inLeapYear, inLeapYear);
6095
assert.sameValue(date.daysInYear, daysInYear);
6196
assert.sameValue(date.monthsInYear, 12);

0 commit comments

Comments
 (0)