Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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.add
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 leap0130 = Temporal.PlainDate.from({ year: 1739, monthCode: "M01", day: 30, calendar }, options);
const leap1230 = Temporal.PlainDate.from({ year: 1739, monthCode: "M12", day: 30, calendar }, options);
const common0130 = Temporal.PlainDate.from({ year: 1740, monthCode: "M01", day: 30, calendar }, options);

const months1 = new Temporal.Duration(0, 1);
const months1n = new Temporal.Duration(0, -1);

TemporalHelpers.assertPlainDate(
common1230.add(months1),
1738, 13, "M13", 5, "Adding 1 month to last day of Mesori constrains to day 5 of common-year epagomenal month",
"am", 1738);
assert.throws(RangeError, function () {
common1230.add(months1, options);
}, "Adding 1 month to last day of Mesori rejects in common year");

TemporalHelpers.assertPlainDate(
leap1230.add(months1),
1739, 13, "M13", 6, "Adding 1 month to last day of Mesori constrains to day 6 of leap-year epagomenal month",
"am", 1739);
assert.throws(RangeError, function () {
leap1230.add(months1, options);
}, "Adding 1 month to last day of Mesori rejects in leap year");

TemporalHelpers.assertPlainDate(
leap0130.add(months1n),
1738, 13, "M13", 5, "Subtracting 1 month from last day of Thout constrains to day 5 of common-year epagomenal month",
"am", 1738);
assert.throws(RangeError, function () {
leap0130.add(months1n, options);
}, "Subtracting 1 month from last day of Thout rejects in common year");

TemporalHelpers.assertPlainDate(
common0130.add(months1n),
1739, 13, "M13", 6, "Subtracting 1 month from last day of Thout constrains to day 6 of leap-year epagomenal month",
"am", 1739);
assert.throws(RangeError, function () {
common0130.add(months1n, options);
}, "Subtracting 1 month from last day of Thout rejects in leap year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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.add
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 leap0130 = Temporal.PlainDate.from({ year: 7515, monthCode: "M01", day: 30, calendar }, options);
const leap1230 = Temporal.PlainDate.from({ year: 7515, monthCode: "M12", day: 30, calendar }, options);
const common0130 = Temporal.PlainDate.from({ year: 7516, monthCode: "M01", day: 30, calendar }, options);

const months1 = new Temporal.Duration(0, 1);
const months1n = new Temporal.Duration(0, -1);

TemporalHelpers.assertPlainDate(
common1230.add(months1),
7514, 13, "M13", 5, "Adding 1 month to last day of Nahase constrains to day 5 of common-year epagomenal month",
"aa", 7514);
assert.throws(RangeError, function () {
common1230.add(months1, options);
}, "Adding 1 month to last day of Nahase rejects in common year");

TemporalHelpers.assertPlainDate(
leap1230.add(months1),
7515, 13, "M13", 6, "Adding 1 month to last day of Nahase constrains to day 6 of leap-year epagomenal month",
"aa", 7515);
assert.throws(RangeError, function () {
leap1230.add(months1, options);
}, "Adding 1 month to last day of Nahase rejects in leap year");

TemporalHelpers.assertPlainDate(
leap0130.add(months1n),
7514, 13, "M13", 5, "Subtracting 1 month from last day of Maskaram constrains to day 5 of common-year epagomenal month",
"aa", 7514);
assert.throws(RangeError, function () {
leap0130.add(months1n, options);
}, "Subtracting 1 month from last day of Maskaram rejects in common year");

TemporalHelpers.assertPlainDate(
common0130.add(months1n),
7515, 13, "M13", 6, "Subtracting 1 month from last day of Maskaram constrains to day 6 of leap-year epagomenal month",
"aa", 7515);
assert.throws(RangeError, function () {
common0130.add(months1n, options);
}, "Subtracting 1 month from last day of Maskaram rejects in leap year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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.add
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 leap0130 = Temporal.PlainDate.from({ year: 2015, monthCode: "M01", day: 30, calendar }, options);
const leap1230 = Temporal.PlainDate.from({ year: 2015, monthCode: "M12", day: 30, calendar }, options);
const common0130 = Temporal.PlainDate.from({ year: 2016, monthCode: "M01", day: 30, calendar }, options);

const months1 = new Temporal.Duration(0, 1);
const months1n = new Temporal.Duration(0, -1);

TemporalHelpers.assertPlainDate(
common1230.add(months1),
2014, 13, "M13", 5, "Adding 1 month to last day of Nahase constrains to day 5 of common-year epagomenal month",
"am", 2014);
assert.throws(RangeError, function () {
common1230.add(months1, options);
}, "Adding 1 month to last day of Nahase rejects in common year");

TemporalHelpers.assertPlainDate(
leap1230.add(months1),
2015, 13, "M13", 6, "Adding 1 month to last day of Nahase constrains to day 6 of leap-year epagomenal month",
"am", 2015);
assert.throws(RangeError, function () {
leap1230.add(months1, options);
}, "Adding 1 month to last day of Nahase rejects in leap year");

TemporalHelpers.assertPlainDate(
leap0130.add(months1n),
2014, 13, "M13", 5, "Subtracting 1 month from last day of Maskaram constrains to day 5 of common-year epagomenal month",
"am", 2014);
assert.throws(RangeError, function () {
leap0130.add(months1n, options);
}, "Subtracting 1 month from last day of Maskaram rejects in common year");

TemporalHelpers.assertPlainDate(
common0130.add(months1n),
2015, 13, "M13", 6, "Subtracting 1 month from last day of Maskaram constrains to day 6 of leap-year epagomenal month",
"am", 2015);
assert.throws(RangeError, function () {
common0130.add(months1n, options);
}, "Subtracting 1 month from last day of Maskaram rejects in leap year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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.add
description: Check various basic calculations involving leap years (coptic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/

const calendar = "coptic";
const options = { overflow: "reject" };

const leapDay = Temporal.PlainDate.from({ year: 1739, monthCode: "M13", day: 6, calendar }, options);

const years1 = new Temporal.Duration(1);
const years1n = new Temporal.Duration(-1);
const years4 = new Temporal.Duration(4);
const years4n = new Temporal.Duration(-4);

TemporalHelpers.assertPlainDate(
leapDay.add(years1),
1740, 13, "M13", 5, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
"am", 1740);
assert.throws(RangeError, function () {
leapDay.add(years1, options);
}, "Adding 1 year to leap day rejects");

TemporalHelpers.assertPlainDate(
leapDay.add(years1n),
1738, 13, "M13", 5, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
"am", 1738);
assert.throws(RangeError, function () {
leapDay.add(years1n, options);
}, "Subtracting 1 year from leap day rejects");

TemporalHelpers.assertPlainDate(
leapDay.add(years4, options),
1743, 13, "M13", 6, "Adding 4 years to leap day goes to the next leap day",
"am", 1743);

TemporalHelpers.assertPlainDate(
leapDay.add(years4n, options),
1735, 13, "M13", 6, "Subtracting 4 years from leap day goes to the previous leap day",
"am", 1735);
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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.add
description: Check various basic calculations involving leap years (ethioaa calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/

const calendar = "ethioaa";
const options = { overflow: "reject" };

const leapDay = Temporal.PlainDate.from({ year: 7515, monthCode: "M13", day: 6, calendar }, options);

const years1 = new Temporal.Duration(1);
const years1n = new Temporal.Duration(-1);
const years4 = new Temporal.Duration(4);
const years4n = new Temporal.Duration(-4);

TemporalHelpers.assertPlainDate(
leapDay.add(years1),
7516, 13, "M13", 5, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
"aa", 7516);
assert.throws(RangeError, function () {
leapDay.add(years1, options);
}, "Adding 1 year to leap day rejects");

TemporalHelpers.assertPlainDate(
leapDay.add(years1n),
7514, 13, "M13", 5, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
"aa", 7514);
assert.throws(RangeError, function () {
leapDay.add(years1n, options);
}, "Subtracting 1 year from leap day rejects");

TemporalHelpers.assertPlainDate(
leapDay.add(years4, options),
7519, 13, "M13", 6, "Adding 4 years to leap day goes to the next leap day",
"aa", 7519);

TemporalHelpers.assertPlainDate(
leapDay.add(years4n, options),
7511, 13, "M13", 6, "Subtracting 4 years from leap day goes to the previous leap day",
"aa", 7511);
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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.add
description: Check various basic calculations involving leap years (ethiopic calendar)
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/

const calendar = "ethiopic";
const options = { overflow: "reject" };

const leapDay = Temporal.PlainDate.from({ year: 2015, monthCode: "M13", day: 6, calendar }, options);

const years1 = new Temporal.Duration(1);
const years1n = new Temporal.Duration(-1);
const years4 = new Temporal.Duration(4);
const years4n = new Temporal.Duration(-4);

TemporalHelpers.assertPlainDate(
leapDay.add(years1),
2016, 13, "M13", 5, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
"am", 2016);
assert.throws(RangeError, function () {
leapDay.add(years1, options);
}, "Adding 1 year to leap day rejects");

TemporalHelpers.assertPlainDate(
leapDay.add(years1n),
2014, 13, "M13", 5, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
"am", 2014);
assert.throws(RangeError, function () {
leapDay.add(years1n, options);
}, "Subtracting 1 year from leap day rejects");

TemporalHelpers.assertPlainDate(
leapDay.add(years4, options),
2019, 13, "M13", 6, "Adding 4 years to leap day goes to the next leap day",
"am", 2019);

TemporalHelpers.assertPlainDate(
leapDay.add(years4n, options),
2011, 13, "M13", 6, "Subtracting 4 years from leap day goes to the previous leap day",
"am", 2011);
Loading