From 1e819e2f5cbfd0f9021abfdbd48c07e7a9c7fbea Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 24 Nov 2025 16:49:19 -0800 Subject: [PATCH] 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). --- .../prototype/add/leap-year-coptic.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-ethioaa.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-ethiopic.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-coptic.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-ethioaa.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-ethiopic.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-coptic.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-ethioaa.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-ethiopic.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-coptic.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-ethioaa.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-ethiopic.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-coptic.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-ethioaa.js | 45 +++++++++++++++++++ .../prototype/add/leap-year-ethiopic.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-coptic.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-ethioaa.js | 45 +++++++++++++++++++ .../prototype/subtract/leap-year-ethiopic.js | 45 +++++++++++++++++++ 18 files changed, 810 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/leap-year-coptic.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethioaa.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethiopic.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-coptic.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethioaa.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethiopic.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-coptic.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethioaa.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethiopic.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-coptic.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethioaa.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethiopic.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-coptic.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethioaa.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethiopic.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-coptic.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethioaa.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethiopic.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/leap-year-coptic.js b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-coptic.js new file mode 100644 index 0000000000..546a83b876 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-coptic.js @@ -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); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethioaa.js b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethioaa.js new file mode 100644 index 0000000000..2239c9f30c --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethioaa.js @@ -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); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethiopic.js b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethiopic.js new file mode 100644 index 0000000000..3dd29af944 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-ethiopic.js @@ -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); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-coptic.js b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-coptic.js new file mode 100644 index 0000000000..c0d0ac4bcf --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-coptic.js @@ -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); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethioaa.js b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethioaa.js new file mode 100644 index 0000000000..1b2bc92106 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethioaa.js @@ -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); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethiopic.js b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethiopic.js new file mode 100644 index 0000000000..6266d7089b --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-ethiopic.js @@ -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); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-coptic.js b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-coptic.js new file mode 100644 index 0000000000..fc1e8c8f0e --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-coptic.js @@ -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); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethioaa.js b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethioaa.js new file mode 100644 index 0000000000..0912d013a0 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethioaa.js @@ -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); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethiopic.js b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethiopic.js new file mode 100644 index 0000000000..01c5070e5c --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-ethiopic.js @@ -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); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-coptic.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-coptic.js new file mode 100644 index 0000000000..022b26a887 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-coptic.js @@ -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); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethioaa.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethioaa.js new file mode 100644 index 0000000000..650ea9e019 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethioaa.js @@ -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); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethiopic.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethiopic.js new file mode 100644 index 0000000000..146e91ac96 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-ethiopic.js @@ -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); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-coptic.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-coptic.js new file mode 100644 index 0000000000..fbea100078 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-coptic.js @@ -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); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethioaa.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethioaa.js new file mode 100644 index 0000000000..925df31596 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethioaa.js @@ -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); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethiopic.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethiopic.js new file mode 100644 index 0000000000..0b8cb87c4e --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-ethiopic.js @@ -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); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-coptic.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-coptic.js new file mode 100644 index 0000000000..b388147676 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-coptic.js @@ -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); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethioaa.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethioaa.js new file mode 100644 index 0000000000..4bd883f35e --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethioaa.js @@ -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); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethiopic.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethiopic.js new file mode 100644 index 0000000000..dd17f8868d --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-ethiopic.js @@ -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);