mirror of
https://github.com/tc39/test262.git
synced 2025-11-29 18:13:13 +01:00
Intl Era Monthcode: Addition on leap day in Orthodox calendars
This adds tests for addition and subtraction on leap day (M13-06) and constraining to M13-05 in common years for the three Orthodox calendars (coptic, ethioaa, ethiopic).
This commit is contained in:
parent
e7da3e0c83
commit
1e819e2f5c
45
test/intl402/Temporal/PlainDate/prototype/add/leap-year-coptic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDate/prototype/add/leap-year-coptic.js
vendored
Normal file
@ -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);
|
||||||
45
test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethioaa.js
vendored
Normal file
45
test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethioaa.js
vendored
Normal file
@ -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);
|
||||||
45
test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethiopic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethiopic.js
vendored
Normal file
@ -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);
|
||||||
45
test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-coptic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-coptic.js
vendored
Normal file
@ -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.subtract
|
||||||
|
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.subtract(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.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(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.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(years4, options),
|
||||||
|
1743, 13, "M13", 6, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 1743);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(years4n, options),
|
||||||
|
1735, 13, "M13", 6, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 1735);
|
||||||
45
test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethioaa.js
vendored
Normal file
45
test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethioaa.js
vendored
Normal file
@ -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.subtract
|
||||||
|
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.subtract(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.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(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.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(years4, options),
|
||||||
|
7519, 13, "M13", 6, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"aa", 7519);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(years4n, options),
|
||||||
|
7511, 13, "M13", 6, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"aa", 7511);
|
||||||
45
test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethiopic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethiopic.js
vendored
Normal file
@ -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.subtract
|
||||||
|
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.subtract(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.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(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.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(years4, options),
|
||||||
|
2019, 13, "M13", 6, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 2019);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.subtract(years4n, options),
|
||||||
|
2011, 13, "M13", 6, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 2011);
|
||||||
45
test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-coptic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-coptic.js
vendored
Normal file
@ -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.plaindatetime.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.PlainDateTime.from({ year: 1739, monthCode: "M13", day: 6, hour: 12, minute: 34, 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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1),
|
||||||
|
1740, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1n),
|
||||||
|
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years4, options),
|
||||||
|
1743, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 1743);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.add(years4n, options),
|
||||||
|
1735, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 1735);
|
||||||
45
test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethioaa.js
vendored
Normal file
45
test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethioaa.js
vendored
Normal file
@ -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.plaindatetime.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.PlainDateTime.from({ year: 7515, monthCode: "M13", day: 6, hour: 12, minute: 34, 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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1),
|
||||||
|
7516, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1n),
|
||||||
|
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years4, options),
|
||||||
|
7519, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"aa", 7519);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.add(years4n, options),
|
||||||
|
7511, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"aa", 7511);
|
||||||
45
test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethiopic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethiopic.js
vendored
Normal file
@ -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.plaindatetime.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.PlainDateTime.from({ year: 2015, monthCode: "M13", day: 6, hour: 12, minute: 34, 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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1),
|
||||||
|
2016, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1n),
|
||||||
|
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years4, options),
|
||||||
|
2019, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 2019);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.add(years4n, options),
|
||||||
|
2011, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 2011);
|
||||||
45
test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-coptic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-coptic.js
vendored
Normal file
@ -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.plaindatetime.prototype.subtract
|
||||||
|
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.PlainDateTime.from({ year: 1739, monthCode: "M13", day: 6, hour: 12, minute: 34, 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.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1),
|
||||||
|
1740, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 1740);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1n),
|
||||||
|
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 1738);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4, options),
|
||||||
|
1743, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 1743);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4n, options),
|
||||||
|
1735, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 1735);
|
||||||
45
test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethioaa.js
vendored
Normal file
45
test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethioaa.js
vendored
Normal file
@ -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.plaindatetime.prototype.subtract
|
||||||
|
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.PlainDateTime.from({ year: 7515, monthCode: "M13", day: 6, hour: 12, minute: 34, 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.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1),
|
||||||
|
7516, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
|
||||||
|
"aa", 7516);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1n),
|
||||||
|
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
|
||||||
|
"aa", 7514);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4, options),
|
||||||
|
7519, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"aa", 7519);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4n, options),
|
||||||
|
7511, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"aa", 7511);
|
||||||
45
test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethiopic.js
vendored
Normal file
45
test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethiopic.js
vendored
Normal file
@ -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.plaindatetime.prototype.subtract
|
||||||
|
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.PlainDateTime.from({ year: 2015, monthCode: "M13", day: 6, hour: 12, minute: 34, 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.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1),
|
||||||
|
2016, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 2016);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1n),
|
||||||
|
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 2014);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4, options),
|
||||||
|
2019, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 2019);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4n, options),
|
||||||
|
2011, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 2011);
|
||||||
45
test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-coptic.js
vendored
Normal file
45
test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-coptic.js
vendored
Normal file
@ -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.zoneddatetime.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.ZonedDateTime.from({ year: 1739, monthCode: "M13", day: 6, hour: 12, minute: 34, timeZone: "UTC", 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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1).toPlainDateTime(),
|
||||||
|
1740, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1n).toPlainDateTime(),
|
||||||
|
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years4, options).toPlainDateTime(),
|
||||||
|
1743, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 1743);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.add(years4n, options).toPlainDateTime(),
|
||||||
|
1735, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 1735);
|
||||||
45
test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethioaa.js
vendored
Normal file
45
test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethioaa.js
vendored
Normal file
@ -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.zoneddatetime.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.ZonedDateTime.from({ year: 7515, monthCode: "M13", day: 6, hour: 12, minute: 34, timeZone: "UTC", 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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1).toPlainDateTime(),
|
||||||
|
7516, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1n).toPlainDateTime(),
|
||||||
|
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years4, options).toPlainDateTime(),
|
||||||
|
7519, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"aa", 7519);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.add(years4n, options).toPlainDateTime(),
|
||||||
|
7511, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"aa", 7511);
|
||||||
45
test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethiopic.js
vendored
Normal file
45
test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethiopic.js
vendored
Normal file
@ -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.zoneddatetime.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.ZonedDateTime.from({ year: 2015, monthCode: "M13", day: 6, hour: 12, minute: 34, timeZone: "UTC", 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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1).toPlainDateTime(),
|
||||||
|
2016, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years1n).toPlainDateTime(),
|
||||||
|
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "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.assertPlainDateTime(
|
||||||
|
leapDay.add(years4, options).toPlainDateTime(),
|
||||||
|
2019, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 2019);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.add(years4n, options).toPlainDateTime(),
|
||||||
|
2011, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 2011);
|
||||||
45
test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-coptic.js
vendored
Normal file
45
test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-coptic.js
vendored
Normal file
@ -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.zoneddatetime.prototype.subtract
|
||||||
|
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.ZonedDateTime.from({ year: 1739, monthCode: "M13", day: 6, hour: 12, minute: 34, timeZone: "UTC", 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.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1).toPlainDateTime(),
|
||||||
|
1740, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 1740);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1n).toPlainDateTime(),
|
||||||
|
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 1738);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4, options).toPlainDateTime(),
|
||||||
|
1743, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 1743);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4n, options).toPlainDateTime(),
|
||||||
|
1735, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 1735);
|
||||||
45
test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethioaa.js
vendored
Normal file
45
test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethioaa.js
vendored
Normal file
@ -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.zoneddatetime.prototype.subtract
|
||||||
|
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.ZonedDateTime.from({ year: 7515, monthCode: "M13", day: 6, hour: 12, minute: 34, timeZone: "UTC", 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.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1).toPlainDateTime(),
|
||||||
|
7516, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
|
||||||
|
"aa", 7516);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1n).toPlainDateTime(),
|
||||||
|
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
|
||||||
|
"aa", 7514);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4, options).toPlainDateTime(),
|
||||||
|
7519, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"aa", 7519);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4n, options).toPlainDateTime(),
|
||||||
|
7511, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"aa", 7511);
|
||||||
45
test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethiopic.js
vendored
Normal file
45
test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethiopic.js
vendored
Normal file
@ -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.zoneddatetime.prototype.subtract
|
||||||
|
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.ZonedDateTime.from({ year: 2015, monthCode: "M13", day: 6, hour: 12, minute: 34, timeZone: "UTC", 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.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1).toPlainDateTime(),
|
||||||
|
2016, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Adding 1 year to leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 2016);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1, options);
|
||||||
|
}, "Adding 1 year to leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years1n).toPlainDateTime(),
|
||||||
|
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from leap day constrains to day 5 of epagomenal month",
|
||||||
|
"am", 2014);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.subtract(years1n, options);
|
||||||
|
}, "Subtracting 1 year from leap day rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4, options).toPlainDateTime(),
|
||||||
|
2019, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Adding 4 years to leap day goes to the next leap day",
|
||||||
|
"am", 2019);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.subtract(years4n, options).toPlainDateTime(),
|
||||||
|
2011, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Subtracting 4 years from leap day goes to the previous leap day",
|
||||||
|
"am", 2011);
|
||||||
Loading…
x
Reference in New Issue
Block a user