From fc5ea1f700a10c3845bcfe4b0101b167a38fadd4 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 27 Nov 2025 12:18:38 -0800 Subject: [PATCH] Intl Era Monthcode: Tests for constraining day in Hebrew leap years Adds tests for constraining 30 Adar I to 29 Adar when moving from a leap year to a common year, by the add(), subtract(), or with() methods. Constraining of the month code is already tested in leap-months-hebrew.js. --- .../prototype/add/leap-year-hebrew.js | 37 +++++++++++++++++++ .../prototype/subtract/leap-year-hebrew.js | 37 +++++++++++++++++++ .../prototype/with/leap-year-hebrew.js | 26 +++++++++++++ .../prototype/add/leap-year-hebrew.js | 37 +++++++++++++++++++ .../prototype/subtract/leap-year-hebrew.js | 37 +++++++++++++++++++ .../prototype/with/leap-year-hebrew.js | 26 +++++++++++++ .../prototype/add/leap-year-hebrew.js | 37 +++++++++++++++++++ .../prototype/subtract/leap-year-hebrew.js | 37 +++++++++++++++++++ .../prototype/with/leap-year-hebrew.js | 26 +++++++++++++ 9 files changed, 300 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/with/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-hebrew.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-hebrew.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/leap-year-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-hebrew.js new file mode 100644 index 0000000000..1526a7534b --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/leap-year-hebrew.js @@ -0,0 +1,37 @@ +// 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 constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const years1 = new Temporal.Duration(1); +const years1n = new Temporal.Duration(-1); + +const adarI = Temporal.PlainDate.from({ year: 5782, monthCode: "M05L", day: 30, calendar }, options); + +TemporalHelpers.assertPlainDate( + adarI.add(years1), + 5783, 6, "M06", 29, "Adding 1 year to 30 Adar I constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.add(years1, options); +}, "Adding 1 year to 30 Adar I rejects (either because the month or day would be constrained)"); + +TemporalHelpers.assertPlainDate( + adarI.add(years1n), + 5781, 6, "M06", 29, "Subtracting 1 year from 30 Adar I constrains to 29 Adar", + "am", 5781); +assert.throws(RangeError, function () { + adarI.add(years1n, options); +}, "Subtracting 1 year from 30 Adar I rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-hebrew.js new file mode 100644 index 0000000000..c988fc0454 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-year-hebrew.js @@ -0,0 +1,37 @@ +// 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 constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const years1 = new Temporal.Duration(-1); +const years1n = new Temporal.Duration(1); + +const adarI = Temporal.PlainDate.from({ year: 5782, monthCode: "M05L", day: 30, calendar }, options); + +TemporalHelpers.assertPlainDate( + adarI.subtract(years1), + 5783, 6, "M06", 29, "Adding 1 year to 30 Adar I constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.subtract(years1, options); +}, "Adding 1 year to 30 Adar I rejects (either because the month or day would be constrained)"); + +TemporalHelpers.assertPlainDate( + adarI.subtract(years1n), + 5781, 6, "M06", 29, "Subtracting 1 year from 30 Adar I constrains to 29 Adar", + "am", 5781); +assert.throws(RangeError, function () { + adarI.subtract(years1n, options); +}, "Subtracting 1 year from 30 Adar I rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/PlainDate/prototype/with/leap-year-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/with/leap-year-hebrew.js new file mode 100644 index 0000000000..22c8aae7ad --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/with/leap-year-hebrew.js @@ -0,0 +1,26 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.with +description: Check constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const adarI = Temporal.PlainDate.from({ year: 5782, monthCode: "M05L", day: 30, calendar }, options); + +TemporalHelpers.assertPlainDate( + adarI.with({ year: 5783 }), + 5783, 6, "M06", 29, "Changing 30 Adar I to common year constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.with({ year: 5783 }, options); +}, "Changing 30 Adar I to common year rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-hebrew.js new file mode 100644 index 0000000000..01d8540413 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-year-hebrew.js @@ -0,0 +1,37 @@ +// 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 constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const years1 = new Temporal.Duration(1); +const years1n = new Temporal.Duration(-1); + +const adarI = Temporal.PlainDateTime.from({ year: 5782, monthCode: "M05L", day: 30, hour: 12, minute: 34, calendar }, options); + +TemporalHelpers.assertPlainDateTime( + adarI.add(years1), + 5783, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Adding 1 year to 30 Adar I constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.add(years1, options); +}, "Adding 1 year to 30 Adar I rejects (either because the month or day would be constrained)"); + +TemporalHelpers.assertPlainDateTime( + adarI.add(years1n), + 5781, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 30 Adar I constrains to 29 Adar", + "am", 5781); +assert.throws(RangeError, function () { + adarI.add(years1n, options); +}, "Subtracting 1 year from 30 Adar I rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-hebrew.js new file mode 100644 index 0000000000..af51059323 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-year-hebrew.js @@ -0,0 +1,37 @@ +// 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 constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const years1 = new Temporal.Duration(-1); +const years1n = new Temporal.Duration(1); + +const adarI = Temporal.PlainDateTime.from({ year: 5782, monthCode: "M05L", day: 30, hour: 12, minute: 34, calendar }, options); + +TemporalHelpers.assertPlainDateTime( + adarI.subtract(years1), + 5783, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Adding 1 year to 30 Adar I constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.subtract(years1, options); +}, "Adding 1 year to 30 Adar I rejects (either because the month or day would be constrained)"); + +TemporalHelpers.assertPlainDateTime( + adarI.subtract(years1n), + 5781, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 30 Adar I constrains to 29 Adar", + "am", 5781); +assert.throws(RangeError, function () { + adarI.subtract(years1n, options); +}, "Subtracting 1 year from 30 Adar I rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-hebrew.js new file mode 100644 index 0000000000..227186f113 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-hebrew.js @@ -0,0 +1,26 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.with +description: Check constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const adarI = Temporal.PlainDateTime.from({ year: 5782, monthCode: "M05L", day: 30, hour: 12, minute: 34, calendar }, options); + +TemporalHelpers.assertPlainDateTime( + adarI.with({ year: 5783 }), + 5783, 6, "M06", 29, 12, 34, 0, 0, 0, 0,"Changing 30 Adar I to common year constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.with({ year: 5783 }, options); +}, "Changing 30 Adar I to common year rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-hebrew.js new file mode 100644 index 0000000000..d16c198946 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-year-hebrew.js @@ -0,0 +1,37 @@ +// 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 constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const years1 = new Temporal.Duration(1); +const years1n = new Temporal.Duration(-1); + +const adarI = Temporal.ZonedDateTime.from({ year: 5782, monthCode: "M05L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); + +TemporalHelpers.assertPlainDateTime( + adarI.add(years1).toPlainDateTime(), + 5783, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Adding 1 year to 30 Adar I constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.add(years1, options); +}, "Adding 1 year to 30 Adar I rejects (either because the month or day would be constrained)"); + +TemporalHelpers.assertPlainDateTime( + adarI.add(years1n).toPlainDateTime(), + 5781, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 30 Adar I constrains to 29 Adar", + "am", 5781); +assert.throws(RangeError, function () { + adarI.add(years1n, options); +}, "Subtracting 1 year from 30 Adar I rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-hebrew.js new file mode 100644 index 0000000000..6eca6656c9 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-year-hebrew.js @@ -0,0 +1,37 @@ +// 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 constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const years1 = new Temporal.Duration(-1); +const years1n = new Temporal.Duration(1); + +const adarI = Temporal.ZonedDateTime.from({ year: 5782, monthCode: "M05L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); + +TemporalHelpers.assertPlainDateTime( + adarI.subtract(years1).toPlainDateTime(), + 5783, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Adding 1 year to 30 Adar I constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.subtract(years1, options); +}, "Adding 1 year to 30 Adar I rejects (either because the month or day would be constrained)"); + +TemporalHelpers.assertPlainDateTime( + adarI.subtract(years1n).toPlainDateTime(), + 5781, 6, "M06", 29, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 30 Adar I constrains to 29 Adar", + "am", 5781); +assert.throws(RangeError, function () { + adarI.subtract(years1n, options); +}, "Subtracting 1 year from 30 Adar I rejects (either because the month or day would be constrained)"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-hebrew.js new file mode 100644 index 0000000000..60e39337f0 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-hebrew.js @@ -0,0 +1,26 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.with +description: Check constraining days due to leap years (hebrew calendar) +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Adar I (M05L) has 30 days, and in common years will be constrained to Adar +// (M06) which has 29 days. +// See also leap-months-hebrew.js and constrain-day-hebrew.js. + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +const adarI = Temporal.ZonedDateTime.from({ year: 5782, monthCode: "M05L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); + +TemporalHelpers.assertPlainDateTime( + adarI.with({ year: 5783 }).toPlainDateTime(), + 5783, 6, "M06", 29, 12, 34, 0, 0, 0, 0,"Changing 30 Adar I to common year constrains to 29 Adar", + "am", 5783); +assert.throws(RangeError, function () { + adarI.with({ year: 5783 }, options); +}, "Changing 30 Adar I to common year rejects (either because the month or day would be constrained)");