From 90889d25cb360fb823f45b2694ce33ab3a4c3a51 Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Fri, 7 Nov 2025 20:40:59 -0800 Subject: [PATCH] Intl Era Monthcode: Date addition tests for hebrew calendar Co-Authored-By: Jesse Alama Co-Authored-By: Philip Chimento --- .../PlainDate/prototype/add/basic-hebrew.js | 27 +++++ .../prototype/add/leap-months-hebrew.js | 101 ++++++++++++++++++ .../prototype/subtract/basic-hebrew.js | 27 +++++ .../prototype/subtract/leap-months-hebrew.js | 101 ++++++++++++++++++ .../prototype/add/basic-hebrew.js | 27 +++++ .../prototype/add/leap-months-hebrew.js | 101 ++++++++++++++++++ .../prototype/subtract/basic-hebrew.js | 27 +++++ .../prototype/subtract/leap-months-hebrew.js | 101 ++++++++++++++++++ .../prototype/add/basic-hebrew.js | 27 +++++ .../prototype/add/leap-months-hebrew.js | 101 ++++++++++++++++++ .../prototype/subtract/basic-hebrew.js | 27 +++++ .../prototype/subtract/leap-months-hebrew.js | 101 ++++++++++++++++++ 12 files changed, 768 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/basic-hebrew.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/leap-months-hebrew.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/basic-hebrew.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-hebrew.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/basic-hebrew.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-hebrew.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-hebrew.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-hebrew.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/basic-hebrew.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-hebrew.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-hebrew.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-hebrew.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/basic-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/add/basic-hebrew.js new file mode 100644 index 0000000000..0355907a06 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/basic-hebrew.js @@ -0,0 +1,27 @@ +// 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: Basic addition and subtraction in the hebrew calendar +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5785, monthCode: "M01", day: 1, calendar }, options).add(days10), + 5785, 1, "M01", 11, "adding 10 days", "am", 5785 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/leap-months-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/add/leap-months-hebrew.js new file mode 100644 index 0000000000..09f460f2b9 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/leap-months-hebrew.js @@ -0,0 +1,101 @@ +// 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: Arithmetic around leap months in the hebrew calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); +const months2 = new Temporal.Duration(0, 2); +const months2n = new Temporal.Duration(0, -2); + +const date1 = Temporal.PlainDate.from({ year: 5784, monthCode: "M04", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(months1), + 5784, 5, "M05", 1, "Adding 1 month to M04 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date1.add(months2), + 5784, 6, "M05L", 1, "Adding 2 months to M04 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 3)), + 5784, 7, "M06", 1, "Adding 3 months to M04 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +const date2 = Temporal.PlainDate.from({ year: 5784, monthCode: "M05L", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(months1), + 5784, 7, "M06", 1, "Adding 1 month to M05L (Adar I) lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5783, monthCode: "M04", day: 1, calendar }, options).add(months2), + 5783, 6, "M06", 1, "Adding 2 months to M04 in non-leap year lands in M06 (no M05L)", + "am", 5783 +); + +const date3 = Temporal.PlainDate.from({ year: 5784, monthCode: "M07", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(months1n), + 5784, 7, "M06", 1, "Subtracting 1 month from M07 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date3.add(months2n), + 5784, 6, "M05L", 1, "Subtracting 2 months from M07 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date3.add(new Temporal.Duration(0, -3)), + 5784, 5, "M05", 1, "Subtracting 3 months from M07 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5784, monthCode: "M06", day: 1, calendar }).add(months1n), + 5784, 6, "M05L", 1, "Subtracting 1 month from M06 (Adar II) in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date2.add(months1n), + 5784, 5, "M05", 1, "Subtracting 1 month from M05L (Adar I) lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5783, monthCode: "M07", day: 1, calendar }).add(months2n), + 5783, 5, "M05", 1, "Subtracting 2 months from M07 in non-leap year lands in M05 (no M05L)", + "am", 5783 +); + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5784, monthCode: "M05L", day: 30, calendar }, options).add(days10), + 5784, 7, "M06", 10, "add 10 days to leap day", "am", 5784 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/basic-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-hebrew.js new file mode 100644 index 0000000000..78b9ee99dd --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-hebrew.js @@ -0,0 +1,27 @@ +// 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: Basic addition and subtraction in the hebrew calendar +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5785, monthCode: "M01", day: 1, calendar }, options).subtract(days10), + 5785, 1, "M01", 11, "adding 10 days", "am", 5785 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-hebrew.js new file mode 100644 index 0000000000..a1365a7833 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-hebrew.js @@ -0,0 +1,101 @@ +// 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: Arithmetic around leap months in the hebrew calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); +const months2 = new Temporal.Duration(0, -2); +const months2n = new Temporal.Duration(0, 2); + +const date1 = Temporal.PlainDate.from({ year: 5784, monthCode: "M04", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(months1), + 5784, 5, "M05", 1, "Adding 1 month to M04 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(months2), + 5784, 6, "M05L", 1, "Adding 2 months to M04 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -3)), + 5784, 7, "M06", 1, "Adding 3 months to M04 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +const date2 = Temporal.PlainDate.from({ year: 5784, monthCode: "M05L", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(months1), + 5784, 7, "M06", 1, "Adding 1 month to M05L (Adar I) lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5783, monthCode: "M04", day: 1, calendar }, options).subtract(months2), + 5783, 6, "M06", 1, "Adding 2 months to M04 in non-leap year lands in M06 (no M05L)", + "am", 5783 +); + +const date3 = Temporal.PlainDate.from({ year: 5784, monthCode: "M07", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(months1n), + 5784, 7, "M06", 1, "Subtracting 1 month from M07 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date3.subtract(months2n), + 5784, 6, "M05L", 1, "Subtracting 2 months from M07 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date3.subtract(new Temporal.Duration(0, 3)), + 5784, 5, "M05", 1, "Subtracting 3 months from M07 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5784, monthCode: "M06", day: 1, calendar }).subtract(months1n), + 5784, 6, "M05L", 1, "Subtracting 1 month from M06 (Adar II) in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + date2.subtract(months1n), + 5784, 5, "M05", 1, "Subtracting 1 month from M05L (Adar I) lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5783, monthCode: "M07", day: 1, calendar }).subtract(months2n), + 5783, 5, "M05", 1, "Subtracting 2 months from M07 in non-leap year lands in M05 (no M05L)", + "am", 5783 +); + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 5784, monthCode: "M05L", day: 30, calendar }, options).subtract(days10), + 5784, 7, "M06", 10, "add 10 days to leap day", "am", 5784 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/basic-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-hebrew.js new file mode 100644 index 0000000000..62dd3012bc --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-hebrew.js @@ -0,0 +1,27 @@ +// 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: Basic addition and subtraction in the hebrew calendar +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5785, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).add(days10), + 5785, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "adding 10 days", "am", 5785 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-hebrew.js new file mode 100644 index 0000000000..42f9822509 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-hebrew.js @@ -0,0 +1,101 @@ +// 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: Arithmetic around leap months in the hebrew calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); +const months2 = new Temporal.Duration(0, 2); +const months2n = new Temporal.Duration(0, -2); + +const date1 = Temporal.PlainDateTime.from({ year: 5784, monthCode: "M04", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M04 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(months2), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 3)), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 3 months to M04 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +const date2 = Temporal.PlainDateTime.from({ year: 5784, monthCode: "M05L", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(months1), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M05L (Adar I) lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5783, monthCode: "M04", day: 1, hour: 12, minute: 34, calendar }, options).add(months2), + 5783, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in non-leap year lands in M06 (no M05L)", + "am", 5783 +); + +const date3 = Temporal.PlainDateTime.from({ year: 5784, monthCode: "M07", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(months1n), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M07 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(months2n), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(new Temporal.Duration(0, -3)), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M07 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5784, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }).add(months1n), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 (Adar II) in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(months1n), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05L (Adar I) lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5783, monthCode: "M07", day: 1, hour: 12, minute: 34, calendar }).add(months2n), + 5783, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in non-leap year lands in M05 (no M05L)", + "am", 5783 +); + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5784, monthCode: "M05L", day: 30, hour: 12, minute: 34, calendar }, options).add(days10), + 5784, 7, "M06", 10, 12, 34, 0, 0, 0, 0, "add 10 days to leap day", "am", 5784 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-hebrew.js new file mode 100644 index 0000000000..119a8f9990 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-hebrew.js @@ -0,0 +1,27 @@ +// 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: Basic addition and subtraction in the hebrew calendar +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5785, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).subtract(days10), + 5785, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "adding 10 days", "am", 5785 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-hebrew.js new file mode 100644 index 0000000000..f4f99d4631 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-hebrew.js @@ -0,0 +1,101 @@ +// 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: Arithmetic around leap months in the hebrew calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); +const months2 = new Temporal.Duration(0, -2); +const months2n = new Temporal.Duration(0, 2); + +const date1 = Temporal.PlainDateTime.from({ year: 5784, monthCode: "M04", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M04 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months2), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -3)), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 3 months to M04 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +const date2 = Temporal.PlainDateTime.from({ year: 5784, monthCode: "M05L", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M05L (Adar I) lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5783, monthCode: "M04", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months2), + 5783, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in non-leap year lands in M06 (no M05L)", + "am", 5783 +); + +const date3 = Temporal.PlainDateTime.from({ year: 5784, monthCode: "M07", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(months1n), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M07 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(months2n), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(new Temporal.Duration(0, 3)), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M07 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5784, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }).subtract(months1n), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 (Adar II) in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1n), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05L (Adar I) lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5783, monthCode: "M07", day: 1, hour: 12, minute: 34, calendar }).subtract(months2n), + 5783, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in non-leap year lands in M05 (no M05L)", + "am", 5783 +); + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 5784, monthCode: "M05L", day: 30, hour: 12, minute: 34, calendar }, options).subtract(days10), + 5784, 7, "M06", 10, 12, 34, 0, 0, 0, 0, "add 10 days to leap day", "am", 5784 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-hebrew.js new file mode 100644 index 0000000000..712f2e8ef1 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-hebrew.js @@ -0,0 +1,27 @@ +// 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: Basic addition and subtraction in the hebrew calendar +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5785, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 5785, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "adding 10 days", "am", 5785 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-hebrew.js new file mode 100644 index 0000000000..cd6d080a86 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-hebrew.js @@ -0,0 +1,101 @@ +// 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: Arithmetic around leap months in the hebrew calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); +const months2 = new Temporal.Duration(0, 2); +const months2n = new Temporal.Duration(0, -2); + +const date1 = Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M04", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1).toPlainDateTime(), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M04 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(months2).toPlainDateTime(), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 3)).toPlainDateTime(), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 3 months to M04 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +const date2 = Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M05L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(months1).toPlainDateTime(), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M05L (Adar I) lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5783, monthCode: "M04", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2).toPlainDateTime(), + 5783, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in non-leap year lands in M06 (no M05L)", + "am", 5783 +); + +const date3 = Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M07", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(months1n).toPlainDateTime(), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M07 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(months2n).toPlainDateTime(), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(new Temporal.Duration(0, -3)).toPlainDateTime(), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M07 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(months1n).toPlainDateTime(), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 (Adar II) in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(months1n).toPlainDateTime(), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05L (Adar I) lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5783, monthCode: "M07", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(months2n).toPlainDateTime(), + 5783, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in non-leap year lands in M05 (no M05L)", + "am", 5783 +); + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M05L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 5784, 7, "M06", 10, 12, 34, 0, 0, 0, 0, "add 10 days to leap day", "am", 5784 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-hebrew.js new file mode 100644 index 0000000000..8fcf47ec77 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-hebrew.js @@ -0,0 +1,27 @@ +// 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: Basic addition and subtraction in the hebrew calendar +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5785, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 5785, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "adding 10 days", "am", 5785 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-hebrew.js new file mode 100644 index 0000000000..1a52d09812 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-hebrew.js @@ -0,0 +1,101 @@ +// 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: Arithmetic around leap months in the hebrew calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "hebrew"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); +const months2 = new Temporal.Duration(0, -2); +const months2n = new Temporal.Duration(0, 2); + +const date1 = Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M04", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1).toPlainDateTime(), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M04 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months2).toPlainDateTime(), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -3)).toPlainDateTime(), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 3 months to M04 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +const date2 = Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M05L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1).toPlainDateTime(), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 1 month to M05L (Adar I) lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5783, monthCode: "M04", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2).toPlainDateTime(), + 5783, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Adding 2 months to M04 in non-leap year lands in M06 (no M05L)", + "am", 5783 +); + +const date3 = Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M07", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(months1n).toPlainDateTime(), + 5784, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M07 in leap year lands in M06 (Adar II)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(months2n).toPlainDateTime(), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(new Temporal.Duration(0, 3)).toPlainDateTime(), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M07 in leap year lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(months1n).toPlainDateTime(), + 5784, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 (Adar II) in leap year lands in M05L (Adar I)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1n).toPlainDateTime(), + 5784, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05L (Adar I) lands in M05 (Shevat)", + "am", 5784 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5783, monthCode: "M07", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(months2n).toPlainDateTime(), + 5783, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M07 in non-leap year lands in M05 (no M05L)", + "am", 5783 +); + +// Weeks + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M05L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 5784, 7, "M06", 10, 12, 34, 0, 0, 0, 0, "add 10 days to leap day", "am", 5784 +);