Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different approximations in the observational Islamic calendar #4101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions test/staging/Intl402/Temporal/old/islamic-calendars.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ features: [Temporal]
const tests = [
{
calendar: "islamic",
inLeapYear: false,
daysInYear: 354,
daysInMonth12: 29,
isoDate: "2023-07-18",
choices: [
// Approximations of the observational Islamic calendar as computed by ICU4C.
{
inLeapYear: false,
daysInYear: 354,
daysInMonth12: 29,
isoDate: "2023-07-18",
},

// Approximations of the observational Islamic calendar as computed by ICU4X.
{
inLeapYear: true,
daysInYear: 355,
daysInMonth12: 30,
isoDate: "2023-07-19",
}
],
},
{
calendar: "islamic-umalqura",
Expand All @@ -33,10 +46,23 @@ const tests = [
},
{
calendar: "islamic-rgsa",
inLeapYear: false,
daysInYear: 354,
daysInMonth12: 29,
isoDate: "2023-07-18",
choices: [
// Approximations of the observational Islamic calendar as computed by ICU4C.
{
inLeapYear: false,
daysInYear: 354,
daysInMonth12: 29,
isoDate: "2023-07-18",
},

// Approximations of the observational Islamic calendar as computed by ICU4X.
{
inLeapYear: true,
daysInYear: 355,
daysInMonth12: 30,
isoDate: "2023-07-19",
}
],
},
{
calendar: "islamic-tbla",
Expand All @@ -48,14 +74,23 @@ const tests = [
];

for (const test of tests) {
const { calendar, inLeapYear, daysInYear, daysInMonth12, isoDate } = test;
const { calendar, choices = [test] } = test;
const year = 1445;
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
assert.sameValue(date.calendarId, calendar);
assert.sameValue(date.year, year);
assert.sameValue(date.month, 1);
assert.sameValue(date.monthCode, "M01");
assert.sameValue(date.day, 1);

// Match the possible choice by comparing the ISO date value.
const choice = choices.find(({ isoDate }) => {
return date.toString().startsWith(isoDate);
});
assert(choice !== undefined, `No applicable choice found for calendar: ${calendar}`);

const { inLeapYear, daysInYear, daysInMonth12, isoDate } = choice;

assert.sameValue(date.inLeapYear, inLeapYear);
assert.sameValue(date.daysInYear, daysInYear);
assert.sameValue(date.monthsInYear, 12);
Expand Down
Loading