Intl Era Monthcode: Constrain day in with() in Orthodox calendars

This adds tests for constraining the day when changing the month code
using the with() method in the three Orthodox calendars (coptic,
ethioaa, ethiopic). Adding years is already covered in the
leap-year-*.js tests. The only time that the days need to be
constrained to the end of the month is in the epagomenal month
(M13), since all the other months always have 30 days.
This commit is contained in:
Philip Chimento 2025-11-24 16:53:08 -08:00 committed by Ms2ger
parent 8adac5c382
commit 370e082653
9 changed files with 324 additions and 0 deletions

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (coptic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "coptic";
const options = { overflow: "reject" };
// Years - see leap-year-coptic.js
// Months
const common1230 = Temporal.PlainDate.from({ year: 1738, monthCode: "M12", day: 30, calendar }, options);
const leap1230 = Temporal.PlainDate.from({ year: 1739, monthCode: "M12", day: 30, calendar }, options);
TemporalHelpers.assertPlainDate(
common1230.with({ monthCode: "M13" }),
1738, 13, "M13", 5, "Changing month constrains to day 5 of common-year epagomenal month",
"am", 1738);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDate(
leap1230.with({ monthCode: "M13" }),
1739, 13, "M13", 6, "Changing month constrains to day 6 of leap-year epagomenal month",
"am", 1739);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (ethioaa calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "ethioaa";
const options = { overflow: "reject" };
// Years - see leap-year-ethioaa.js
// Months
const common1230 = Temporal.PlainDate.from({ year: 7514, monthCode: "M12", day: 30, calendar }, options);
const leap1230 = Temporal.PlainDate.from({ year: 7515, monthCode: "M12", day: 30, calendar }, options);
TemporalHelpers.assertPlainDate(
common1230.with({ monthCode: "M13" }),
7514, 13, "M13", 5, "Changing month constrains to day 5 of common-year epagomenal month",
"aa", 7514);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDate(
leap1230.with({ monthCode: "M13" }),
7515, 13, "M13", 6, "Changing month constrains to day 6 of leap-year epagomenal month",
"aa", 7515);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (ethiopic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "ethiopic";
const options = { overflow: "reject" };
// Years - see leap-year-ethiopic.js
// Months
const common1230 = Temporal.PlainDate.from({ year: 2014, monthCode: "M12", day: 30, calendar }, options);
const leap1230 = Temporal.PlainDate.from({ year: 2015, monthCode: "M12", day: 30, calendar }, options);
TemporalHelpers.assertPlainDate(
common1230.with({ monthCode: "M13" }),
2014, 13, "M13", 5, "Changing month constrains to day 5 of common-year epagomenal month",
"am", 2014);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDate(
leap1230.with({ monthCode: "M13" }),
2015, 13, "M13", 6, "Changing month constrains to day 6 of leap-year epagomenal month",
"am", 2015);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (coptic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "coptic";
const options = { overflow: "reject" };
// Years - see leap-year-coptic.js
// Months
const common1230 = Temporal.PlainDateTime.from({ year: 1738, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
const leap1230 = Temporal.PlainDateTime.from({ year: 1739, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
TemporalHelpers.assertPlainDateTime(
common1230.with({ monthCode: "M13" }),
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
"am", 1738);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDateTime(
leap1230.with({ monthCode: "M13" }),
1739, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
"am", 1739);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (ethioaa calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "ethioaa";
const options = { overflow: "reject" };
// Years - see leap-year-ethioaa.js
// Months
const common1230 = Temporal.PlainDateTime.from({ year: 7514, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
const leap1230 = Temporal.PlainDateTime.from({ year: 7515, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
TemporalHelpers.assertPlainDateTime(
common1230.with({ monthCode: "M13" }),
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
"aa", 7514);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDateTime(
leap1230.with({ monthCode: "M13" }),
7515, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
"aa", 7515);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (ethiopic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "ethiopic";
const options = { overflow: "reject" };
// Years - see leap-year-ethiopic.js
// Months
const common1230 = Temporal.PlainDateTime.from({ year: 2014, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
const leap1230 = Temporal.PlainDateTime.from({ year: 2015, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
TemporalHelpers.assertPlainDateTime(
common1230.with({ monthCode: "M13" }),
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
"am", 2014);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDateTime(
leap1230.with({ monthCode: "M13" }),
2015, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
"am", 2015);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (coptic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "coptic";
const options = { overflow: "reject" };
// Years - see leap-year-coptic.js
// Months
const common1230 = Temporal.ZonedDateTime.from({ year: 1738, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const leap1230 = Temporal.ZonedDateTime.from({ year: 1739, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
TemporalHelpers.assertPlainDateTime(
common1230.with({ monthCode: "M13" }).toPlainDateTime(),
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
"am", 1738);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDateTime(
leap1230.with({ monthCode: "M13" }).toPlainDateTime(),
1739, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
"am", 1739);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (ethioaa calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "ethioaa";
const options = { overflow: "reject" };
// Years - see leap-year-ethioaa.js
// Months
const common1230 = Temporal.ZonedDateTime.from({ year: 7514, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const leap1230 = Temporal.ZonedDateTime.from({ year: 7515, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
TemporalHelpers.assertPlainDateTime(
common1230.with({ monthCode: "M13" }).toPlainDateTime(),
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
"aa", 7514);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDateTime(
leap1230.with({ monthCode: "M13" }).toPlainDateTime(),
7515, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
"aa", 7515);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.with
description: >
Check various basic calculations involving constraining days to the end of the
epagomenal month (ethiopic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/
const calendar = "ethiopic";
const options = { overflow: "reject" };
// Years - see leap-year-ethiopic.js
// Months
const common1230 = Temporal.ZonedDateTime.from({ year: 2014, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const leap1230 = Temporal.ZonedDateTime.from({ year: 2015, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
TemporalHelpers.assertPlainDateTime(
common1230.with({ monthCode: "M13" }).toPlainDateTime(),
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
"am", 2014);
assert.throws(RangeError, function () {
common1230.with({ monthCode: "M13" }, options);
}, "Changing month to common-year epagomenal month rejects");
TemporalHelpers.assertPlainDateTime(
leap1230.with({ monthCode: "M13" }).toPlainDateTime(),
2015, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
"am", 2015);
assert.throws(RangeError, function () {
leap1230.with({ monthCode: "M13" }, options);
}, "Changing month to leap-year epagomenal month rejects");