mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Remove test data from other calendars
This commit is contained in:
parent
c9ab199907
commit
c7bbdd435f
@ -3,102 +3,35 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal-intl
|
esid: sec-temporal-intl
|
||||||
description: Islamic calendars (note there are 5 variants)
|
description: Islamic calendar "islamic-civil".
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
const calendar = "islamic-civil";
|
||||||
|
|
||||||
// Test data obtained from ICU
|
// Test data obtained from ICU
|
||||||
|
const inLeapYear = true;
|
||||||
|
const daysInYear = 355;
|
||||||
|
const daysInMonth12 = 30;
|
||||||
|
const isoDate = "2023-07-19";
|
||||||
|
|
||||||
const tests = [
|
const year = 1445;
|
||||||
{
|
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
||||||
calendar: "islamic",
|
assert.sameValue(date.calendarId, calendar);
|
||||||
choices: [
|
assert.sameValue(date.year, year);
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4C.
|
assert.sameValue(date.month, 1);
|
||||||
{
|
assert.sameValue(date.monthCode, "M01");
|
||||||
inLeapYear: false,
|
assert.sameValue(date.day, 1);
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 29,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
},
|
|
||||||
|
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4X.
|
assert.sameValue(date.inLeapYear, inLeapYear);
|
||||||
{
|
assert.sameValue(date.daysInYear, daysInYear);
|
||||||
inLeapYear: true,
|
assert.sameValue(date.monthsInYear, 12);
|
||||||
daysInYear: 355,
|
assert.sameValue(date.dayOfYear, 1);
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-umalqura",
|
|
||||||
inLeapYear: false,
|
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-civil",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-rgsa",
|
|
||||||
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.
|
const startOfNextYear = date.with({ year: year + 1 });
|
||||||
{
|
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
||||||
inLeapYear: true,
|
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-tbla",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const test of tests) {
|
const dateMonth12 = date.with({ month: 12 });
|
||||||
const { calendar, choices = [test] } = test;
|
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
||||||
const year = 1445;
|
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
||||||
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);
|
|
||||||
assert.sameValue(date.dayOfYear, 1);
|
|
||||||
const startOfNextYear = date.with({ year: year + 1 });
|
|
||||||
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
|
||||||
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
|
||||||
const dateMonth12 = date.with({ month: 12 });
|
|
||||||
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
|
||||||
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
|
||||||
}
|
|
||||||
|
@ -3,16 +3,15 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal-intl
|
esid: sec-temporal-intl
|
||||||
description: Islamic calendars (note there are 5 variants)
|
description: Islamic calendar "islamic-rgsa".
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
const calendar = "islamic-rgsa";
|
||||||
|
|
||||||
// Test data obtained from ICU
|
// Test data obtained from ICU
|
||||||
|
|
||||||
const tests = [
|
const choices = [
|
||||||
{
|
|
||||||
calendar: "islamic",
|
|
||||||
choices: [
|
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4C.
|
// Approximations of the observational Islamic calendar as computed by ICU4C.
|
||||||
{
|
{
|
||||||
inLeapYear: false,
|
inLeapYear: false,
|
||||||
@ -28,77 +27,33 @@ const tests = [
|
|||||||
daysInMonth12: 30,
|
daysInMonth12: 30,
|
||||||
isoDate: "2023-07-19",
|
isoDate: "2023-07-19",
|
||||||
}
|
}
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-umalqura",
|
|
||||||
inLeapYear: false,
|
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-civil",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-rgsa",
|
|
||||||
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",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const test of tests) {
|
const year = 1445;
|
||||||
const { calendar, choices = [test] } = test;
|
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
||||||
const year = 1445;
|
assert.sameValue(date.calendarId, calendar);
|
||||||
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
assert.sameValue(date.year, year);
|
||||||
assert.sameValue(date.calendarId, calendar);
|
assert.sameValue(date.month, 1);
|
||||||
assert.sameValue(date.year, year);
|
assert.sameValue(date.monthCode, "M01");
|
||||||
assert.sameValue(date.month, 1);
|
assert.sameValue(date.day, 1);
|
||||||
assert.sameValue(date.monthCode, "M01");
|
|
||||||
assert.sameValue(date.day, 1);
|
|
||||||
|
|
||||||
// Match the possible choice by comparing the ISO date value.
|
// Match the possible choice by comparing the ISO date value.
|
||||||
const choice = choices.find(({ isoDate }) => {
|
const choice = choices.find(({ isoDate }) => {
|
||||||
return date.toString().startsWith(isoDate);
|
return date.toString().startsWith(isoDate);
|
||||||
});
|
});
|
||||||
assert(choice !== undefined, `No applicable choice found for calendar: ${calendar}`);
|
assert(choice !== undefined, `No applicable choice found for calendar: ${calendar}`);
|
||||||
|
|
||||||
const { inLeapYear, daysInYear, daysInMonth12, isoDate } = choice;
|
const { inLeapYear, daysInYear, daysInMonth12, isoDate } = choice;
|
||||||
|
|
||||||
assert.sameValue(date.inLeapYear, inLeapYear);
|
assert.sameValue(date.inLeapYear, inLeapYear);
|
||||||
assert.sameValue(date.daysInYear, daysInYear);
|
assert.sameValue(date.daysInYear, daysInYear);
|
||||||
assert.sameValue(date.monthsInYear, 12);
|
assert.sameValue(date.monthsInYear, 12);
|
||||||
assert.sameValue(date.dayOfYear, 1);
|
assert.sameValue(date.dayOfYear, 1);
|
||||||
const startOfNextYear = date.with({ year: year + 1 });
|
|
||||||
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
const startOfNextYear = date.with({ year: year + 1 });
|
||||||
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
||||||
const dateMonth12 = date.with({ month: 12 });
|
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
||||||
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
|
||||||
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
const dateMonth12 = date.with({ month: 12 });
|
||||||
}
|
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
||||||
|
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
||||||
|
@ -3,102 +3,35 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal-intl
|
esid: sec-temporal-intl
|
||||||
description: Islamic calendars (note there are 5 variants)
|
description: Islamic calendar "islamic-tbla".
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
const calendar = "islamic-tbla";
|
||||||
|
|
||||||
// Test data obtained from ICU
|
// Test data obtained from ICU
|
||||||
|
const inLeapYear = true;
|
||||||
|
const daysInYear = 355;
|
||||||
|
const daysInMonth12 = 30;
|
||||||
|
const isoDate = "2023-07-18";
|
||||||
|
|
||||||
const tests = [
|
const year = 1445;
|
||||||
{
|
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
||||||
calendar: "islamic",
|
assert.sameValue(date.calendarId, calendar);
|
||||||
choices: [
|
assert.sameValue(date.year, year);
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4C.
|
assert.sameValue(date.month, 1);
|
||||||
{
|
assert.sameValue(date.monthCode, "M01");
|
||||||
inLeapYear: false,
|
assert.sameValue(date.day, 1);
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 29,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
},
|
|
||||||
|
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4X.
|
assert.sameValue(date.inLeapYear, inLeapYear);
|
||||||
{
|
assert.sameValue(date.daysInYear, daysInYear);
|
||||||
inLeapYear: true,
|
assert.sameValue(date.monthsInYear, 12);
|
||||||
daysInYear: 355,
|
assert.sameValue(date.dayOfYear, 1);
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-umalqura",
|
|
||||||
inLeapYear: false,
|
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-civil",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-rgsa",
|
|
||||||
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.
|
const startOfNextYear = date.with({ year: year + 1 });
|
||||||
{
|
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
||||||
inLeapYear: true,
|
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-tbla",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const test of tests) {
|
const dateMonth12 = date.with({ month: 12 });
|
||||||
const { calendar, choices = [test] } = test;
|
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
||||||
const year = 1445;
|
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
||||||
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);
|
|
||||||
assert.sameValue(date.dayOfYear, 1);
|
|
||||||
const startOfNextYear = date.with({ year: year + 1 });
|
|
||||||
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
|
||||||
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
|
||||||
const dateMonth12 = date.with({ month: 12 });
|
|
||||||
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
|
||||||
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
|
||||||
}
|
|
||||||
|
@ -3,102 +3,35 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal-intl
|
esid: sec-temporal-intl
|
||||||
description: Islamic calendars (note there are 5 variants)
|
description: Islamic calendar "islamic-umalqura".
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
const calendar = "islamic-umalqura";
|
||||||
|
|
||||||
// Test data obtained from ICU
|
// Test data obtained from ICU
|
||||||
|
const inLeapYear = false;
|
||||||
|
const daysInYear = 354;
|
||||||
|
const daysInMonth12 = 30;
|
||||||
|
const isoDate = "2023-07-19";
|
||||||
|
|
||||||
const tests = [
|
const year = 1445;
|
||||||
{
|
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
||||||
calendar: "islamic",
|
assert.sameValue(date.calendarId, calendar);
|
||||||
choices: [
|
assert.sameValue(date.year, year);
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4C.
|
assert.sameValue(date.month, 1);
|
||||||
{
|
assert.sameValue(date.monthCode, "M01");
|
||||||
inLeapYear: false,
|
assert.sameValue(date.day, 1);
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 29,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
},
|
|
||||||
|
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4X.
|
assert.sameValue(date.inLeapYear, inLeapYear);
|
||||||
{
|
assert.sameValue(date.daysInYear, daysInYear);
|
||||||
inLeapYear: true,
|
assert.sameValue(date.monthsInYear, 12);
|
||||||
daysInYear: 355,
|
assert.sameValue(date.dayOfYear, 1);
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-umalqura",
|
|
||||||
inLeapYear: false,
|
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-civil",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-rgsa",
|
|
||||||
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.
|
const startOfNextYear = date.with({ year: year + 1 });
|
||||||
{
|
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
||||||
inLeapYear: true,
|
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-tbla",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const test of tests) {
|
const dateMonth12 = date.with({ month: 12 });
|
||||||
const { calendar, choices = [test] } = test;
|
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
||||||
const year = 1445;
|
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
||||||
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);
|
|
||||||
assert.sameValue(date.dayOfYear, 1);
|
|
||||||
const startOfNextYear = date.with({ year: year + 1 });
|
|
||||||
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
|
||||||
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
|
||||||
const dateMonth12 = date.with({ month: 12 });
|
|
||||||
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
|
||||||
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
|
||||||
}
|
|
||||||
|
@ -3,16 +3,14 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal-intl
|
esid: sec-temporal-intl
|
||||||
description: Islamic calendars (note there are 5 variants)
|
description: Islamic calendar "islamic".
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
// Test data obtained from ICU
|
const calendar = "islamic";
|
||||||
|
|
||||||
const tests = [
|
// Test data obtained from ICU.
|
||||||
{
|
const choices = [
|
||||||
calendar: "islamic",
|
|
||||||
choices: [
|
|
||||||
// Approximations of the observational Islamic calendar as computed by ICU4C.
|
// Approximations of the observational Islamic calendar as computed by ICU4C.
|
||||||
{
|
{
|
||||||
inLeapYear: false,
|
inLeapYear: false,
|
||||||
@ -28,77 +26,33 @@ const tests = [
|
|||||||
daysInMonth12: 30,
|
daysInMonth12: 30,
|
||||||
isoDate: "2023-07-19",
|
isoDate: "2023-07-19",
|
||||||
}
|
}
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-umalqura",
|
|
||||||
inLeapYear: false,
|
|
||||||
daysInYear: 354,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-civil",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-19",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
calendar: "islamic-rgsa",
|
|
||||||
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",
|
|
||||||
inLeapYear: true,
|
|
||||||
daysInYear: 355,
|
|
||||||
daysInMonth12: 30,
|
|
||||||
isoDate: "2023-07-18",
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const test of tests) {
|
const year = 1445;
|
||||||
const { calendar, choices = [test] } = test;
|
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
||||||
const year = 1445;
|
assert.sameValue(date.calendarId, calendar);
|
||||||
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
assert.sameValue(date.year, year);
|
||||||
assert.sameValue(date.calendarId, calendar);
|
assert.sameValue(date.month, 1);
|
||||||
assert.sameValue(date.year, year);
|
assert.sameValue(date.monthCode, "M01");
|
||||||
assert.sameValue(date.month, 1);
|
assert.sameValue(date.day, 1);
|
||||||
assert.sameValue(date.monthCode, "M01");
|
|
||||||
assert.sameValue(date.day, 1);
|
|
||||||
|
|
||||||
// Match the possible choice by comparing the ISO date value.
|
// Match the possible choice by comparing the ISO date value.
|
||||||
const choice = choices.find(({ isoDate }) => {
|
const choice = choices.find(({ isoDate }) => {
|
||||||
return date.toString().startsWith(isoDate);
|
return date.toString().startsWith(isoDate);
|
||||||
});
|
});
|
||||||
assert(choice !== undefined, `No applicable choice found for calendar: ${calendar}`);
|
assert(choice !== undefined, `No applicable choice found for calendar: ${calendar}`);
|
||||||
|
|
||||||
const { inLeapYear, daysInYear, daysInMonth12, isoDate } = choice;
|
const { inLeapYear, daysInYear, daysInMonth12, isoDate } = choice;
|
||||||
|
|
||||||
assert.sameValue(date.inLeapYear, inLeapYear);
|
assert.sameValue(date.inLeapYear, inLeapYear);
|
||||||
assert.sameValue(date.daysInYear, daysInYear);
|
assert.sameValue(date.daysInYear, daysInYear);
|
||||||
assert.sameValue(date.monthsInYear, 12);
|
assert.sameValue(date.monthsInYear, 12);
|
||||||
assert.sameValue(date.dayOfYear, 1);
|
assert.sameValue(date.dayOfYear, 1);
|
||||||
const startOfNextYear = date.with({ year: year + 1 });
|
|
||||||
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
const startOfNextYear = date.with({ year: year + 1 });
|
||||||
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
const lastDayOfThisYear = startOfNextYear.subtract({ days: 1 });
|
||||||
const dateMonth12 = date.with({ month: 12 });
|
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
||||||
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
|
||||||
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
const dateMonth12 = date.with({ month: 12 });
|
||||||
}
|
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
||||||
|
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user