From 1109f32e10e137540b657cf602f25fa178caabf4 Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Fri, 7 Nov 2025 20:40:08 -0800 Subject: [PATCH 1/7] Intl Era Monthcode: Date addition tests for chinese and dangi calendars Co-Authored-By: Jesse Alama Co-Authored-By: Philip Chimento --- .../PlainDate/prototype/add/basic-chinese.js | 61 +++++++++ .../PlainDate/prototype/add/basic-dangi.js | 61 +++++++++ .../prototype/add/leap-months-chinese.js | 126 ++++++++++++++++++ .../prototype/add/leap-months-dangi.js | 126 ++++++++++++++++++ .../prototype/subtract/basic-chinese.js | 61 +++++++++ .../prototype/subtract/basic-dangi.js | 61 +++++++++ .../prototype/subtract/leap-months-chinese.js | 126 ++++++++++++++++++ .../prototype/subtract/leap-months-dangi.js | 126 ++++++++++++++++++ .../prototype/add/basic-chinese.js | 61 +++++++++ .../prototype/add/basic-dangi.js | 61 +++++++++ .../prototype/add/leap-months-chinese.js | 126 ++++++++++++++++++ .../prototype/add/leap-months-dangi.js | 126 ++++++++++++++++++ .../prototype/subtract/basic-chinese.js | 61 +++++++++ .../prototype/subtract/basic-dangi.js | 61 +++++++++ .../prototype/subtract/leap-months-chinese.js | 126 ++++++++++++++++++ .../prototype/subtract/leap-months-dangi.js | 126 ++++++++++++++++++ .../prototype/add/basic-chinese.js | 61 +++++++++ .../prototype/add/basic-dangi.js | 61 +++++++++ .../prototype/add/leap-months-chinese.js | 126 ++++++++++++++++++ .../prototype/add/leap-months-dangi.js | 126 ++++++++++++++++++ .../prototype/subtract/basic-chinese.js | 61 +++++++++ .../prototype/subtract/basic-dangi.js | 61 +++++++++ .../prototype/subtract/leap-months-chinese.js | 126 ++++++++++++++++++ .../prototype/subtract/leap-months-dangi.js | 126 ++++++++++++++++++ 24 files changed, 2244 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/basic-chinese.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/basic-dangi.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/leap-months-chinese.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/leap-months-dangi.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/basic-chinese.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/basic-dangi.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-chinese.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-dangi.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/basic-chinese.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/basic-dangi.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-chinese.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-dangi.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-chinese.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-dangi.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-chinese.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-dangi.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/basic-chinese.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/basic-dangi.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-chinese.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-dangi.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-chinese.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-dangi.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-chinese.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-dangi.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/basic-chinese.js b/test/intl402/Temporal/PlainDate/prototype/add/basic-chinese.js new file mode 100644 index 00000000000..2c3afe86622 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/basic-chinese.js @@ -0,0 +1,61 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M11", day: 1, calendar }, options).add(duration1), + 2019, 12, "M12", 1, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M12", day: 1, calendar }, options).add(duration1), + 2020, 1, "M01", 1, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(months2weeks3), + 2021, 3, "M03", 22, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(months2weeks3), + 2022, 3, "M03", 21, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(days10), + 2021, 1, "M01", 11, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 29, calendar }, options).add(days10), + 2021, 2, "M02", 10, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(days10), + 2022, 1, "M01", 10, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/basic-dangi.js b/test/intl402/Temporal/PlainDate/prototype/add/basic-dangi.js new file mode 100644 index 00000000000..8e32a15c216 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/basic-dangi.js @@ -0,0 +1,61 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M11", day: 1, calendar }, options).add(duration1), + 2019, 12, "M12", 1, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M12", day: 1, calendar }, options).add(duration1), + 2020, 1, "M01", 1, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(months2weeks3), + 2021, 3, "M03", 22, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(months2weeks3), + 2022, 3, "M03", 21, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(days10), + 2021, 1, "M01", 11, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 29, calendar }, options).add(days10), + 2021, 2, "M02", 10, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(days10), + 2022, 1, "M01", 10, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/leap-months-chinese.js b/test/intl402/Temporal/PlainDate/prototype/add/leap-months-chinese.js new file mode 100644 index 00000000000..d7ba584c2ea --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/leap-months-chinese.js @@ -0,0 +1,126 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options).add(years1), + 2020, 1, "M01", 1, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1966, monthCode: "M03L", day: 1, calendar }, options).add(years1), + 1967, 3, "M03", 1, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1938, monthCode: "M07L", day: 30, calendar }, options).add(years1), + 1939, 7, "M07", 29, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 1, calendar }, options).add(months1), + 1947, 4, "M03", 1, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 1, calendar }, options).add(months1), + 1955, 5, "M04", 1, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(months1), + 2020, 4, "M04", 1, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 3)), + 2020, 6, "M05", 1, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(months1n), + 2020, 6, "M05", 1, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDate( + date2.add(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date2.add(new Temporal.Duration(0, -3)), + 2020, 4, "M04", 1, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M05", day: 1, calendar }, options).add(months1n), + 2020, 5, "M04L", 1, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M04L", day: 1, calendar }, options).add(months1n), + 2020, 4, "M04", 1, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).add(months2weeks3), + 1947, 6, "M05", 20, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).add(months2weeks3), + 1955, 7, "M06", 21, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M01", day: 29, calendar }, options).add(months2weeks3), + 1947, 4, "M03", 21, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M06", day: 29, calendar }, options).add(months2weeks3), + 1955, 10, "M09", 20, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).add(days10), + 1955, 5, "M04", 10, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).add(days10), + 1947, 4, "M03", 10, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/leap-months-dangi.js b/test/intl402/Temporal/PlainDate/prototype/add/leap-months-dangi.js new file mode 100644 index 00000000000..4feb90a6b43 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/leap-months-dangi.js @@ -0,0 +1,126 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options).add(years1), + 2020, 1, "M01", 1, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1966, monthCode: "M03L", day: 1, calendar }, options).add(years1), + 1967, 3, "M03", 1, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1938, monthCode: "M07L", day: 30, calendar }, options).add(years1), + 1939, 7, "M07", 29, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 1, calendar }, options).add(months1), + 1947, 4, "M03", 1, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 1, calendar }, options).add(months1), + 1955, 5, "M04", 1, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(months1), + 2020, 4, "M04", 1, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 3)), + 2020, 6, "M05", 1, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(months1n), + 2020, 6, "M05", 1, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDate( + date2.add(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date2.add(new Temporal.Duration(0, -3)), + 2020, 4, "M04", 1, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M05", day: 1, calendar }, options).add(months1n), + 2020, 5, "M04L", 1, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M04L", day: 1, calendar }, options).add(months1n), + 2020, 4, "M04", 1, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).add(months2weeks3), + 1947, 6, "M05", 20, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).add(months2weeks3), + 1955, 7, "M06", 21, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M01", day: 29, calendar }, options).add(months2weeks3), + 1947, 4, "M03", 21, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M06", day: 29, calendar }, options).add(months2weeks3), + 1955, 10, "M09", 20, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).add(days10), + 1955, 5, "M04", 10, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).add(days10), + 1947, 4, "M03", 10, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/basic-chinese.js b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-chinese.js new file mode 100644 index 00000000000..7e85631ac1c --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-chinese.js @@ -0,0 +1,61 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M11", day: 1, calendar }, options).subtract(duration1), + 2019, 12, "M12", 1, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M12", day: 1, calendar }, options).subtract(duration1), + 2020, 1, "M01", 1, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).subtract(months2weeks3), + 2021, 3, "M03", 22, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).subtract(months2weeks3), + 2022, 3, "M03", 21, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).subtract(days10), + 2021, 1, "M01", 11, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 29, calendar }, options).subtract(days10), + 2021, 2, "M02", 10, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).subtract(days10), + 2022, 1, "M01", 10, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/basic-dangi.js b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-dangi.js new file mode 100644 index 00000000000..1fc3f3c77e5 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-dangi.js @@ -0,0 +1,61 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M11", day: 1, calendar }, options).subtract(duration1), + 2019, 12, "M12", 1, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M12", day: 1, calendar }, options).subtract(duration1), + 2020, 1, "M01", 1, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).subtract(months2weeks3), + 2021, 3, "M03", 22, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).subtract(months2weeks3), + 2022, 3, "M03", 21, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).subtract(days10), + 2021, 1, "M01", 11, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 29, calendar }, options).subtract(days10), + 2021, 2, "M02", 10, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).subtract(days10), + 2022, 1, "M01", 10, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-chinese.js b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-chinese.js new file mode 100644 index 00000000000..a47c7f11946 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-chinese.js @@ -0,0 +1,126 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(-1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options).subtract(years1), + 2020, 1, "M01", 1, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1966, monthCode: "M03L", day: 1, calendar }, options).subtract(years1), + 1967, 3, "M03", 1, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1938, monthCode: "M07L", day: 30, calendar }, options).subtract(years1), + 1939, 7, "M07", 29, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 1, calendar }, options).subtract(months1), + 1947, 4, "M03", 1, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 1, calendar }, options).subtract(months1), + 1955, 5, "M04", 1, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(months1), + 2020, 4, "M04", 1, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -3)), + 2020, 6, "M05", 1, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(months1n), + 2020, 6, "M05", 1, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDate( + date2.subtract(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date2.subtract(new Temporal.Duration(0, 3)), + 2020, 4, "M04", 1, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M05", day: 1, calendar }, options).subtract(months1n), + 2020, 5, "M04L", 1, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M04L", day: 1, calendar }, options).subtract(months1n), + 2020, 4, "M04", 1, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).subtract(months2weeks3), + 1947, 6, "M05", 20, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).subtract(months2weeks3), + 1955, 7, "M06", 21, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M01", day: 29, calendar }, options).subtract(months2weeks3), + 1947, 4, "M03", 21, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M06", day: 29, calendar }, options).subtract(months2weeks3), + 1955, 10, "M09", 20, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).subtract(days10), + 1955, 5, "M04", 10, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).subtract(days10), + 1947, 4, "M03", 10, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-dangi.js b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-dangi.js new file mode 100644 index 00000000000..409f058cef4 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/leap-months-dangi.js @@ -0,0 +1,126 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(-1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options).subtract(years1), + 2020, 1, "M01", 1, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1966, monthCode: "M03L", day: 1, calendar }, options).subtract(years1), + 1967, 3, "M03", 1, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1938, monthCode: "M07L", day: 30, calendar }, options).subtract(years1), + 1939, 7, "M07", 29, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 1, calendar }, options).subtract(months1), + 1947, 4, "M03", 1, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 1, calendar }, options).subtract(months1), + 1955, 5, "M04", 1, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(months1), + 2020, 4, "M04", 1, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -3)), + 2020, 6, "M05", 1, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(months1n), + 2020, 6, "M05", 1, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDate( + date2.subtract(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDate( + date2.subtract(new Temporal.Duration(0, 3)), + 2020, 4, "M04", 1, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M05", day: 1, calendar }, options).subtract(months1n), + 2020, 5, "M04L", 1, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 2020, monthCode: "M04L", day: 1, calendar }, options).subtract(months1n), + 2020, 4, "M04", 1, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).subtract(months2weeks3), + 1947, 6, "M05", 20, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).subtract(months2weeks3), + 1955, 7, "M06", 21, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M01", day: 29, calendar }, options).subtract(months2weeks3), + 1947, 4, "M03", 21, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M06", day: 29, calendar }, options).subtract(months2weeks3), + 1955, 10, "M09", 20, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1955, monthCode: "M03L", day: 30, calendar }, options).subtract(days10), + 1955, 5, "M04", 10, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1947, monthCode: "M02L", day: 29, calendar }, options).subtract(days10), + 1947, 4, "M03", 10, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/basic-chinese.js b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-chinese.js new file mode 100644 index 00000000000..b302a658efa --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-chinese.js @@ -0,0 +1,61 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, calendar }, options).add(duration1), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options).add(duration1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).add(days10), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).add(days10), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).add(days10), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/basic-dangi.js b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-dangi.js new file mode 100644 index 00000000000..8bbcc9960f5 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-dangi.js @@ -0,0 +1,61 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, calendar }, options).add(duration1), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options).add(duration1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).add(days10), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).add(days10), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).add(days10), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-chinese.js b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-chinese.js new file mode 100644 index 00000000000..4156c5bb488 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-chinese.js @@ -0,0 +1,126 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).add(years1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).add(years1), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, calendar }, options).add(years1), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, calendar }, options).add(months1), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).add(months1), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 3)), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(months1n), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -3)), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, calendar }, options).add(months1n), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, calendar }, options).add(months1n), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).add(days10), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).add(days10), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-dangi.js b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-dangi.js new file mode 100644 index 00000000000..d05ac34d202 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/leap-months-dangi.js @@ -0,0 +1,126 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).add(years1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).add(years1), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, calendar }, options).add(years1), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, calendar }, options).add(months1), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).add(months1), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 3)), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(months1n), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -3)), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, calendar }, options).add(months1n), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, calendar }, options).add(months1n), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, calendar }, options).add(months2weeks3), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).add(days10), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).add(days10), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-chinese.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-chinese.js new file mode 100644 index 00000000000..c8518690144 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-chinese.js @@ -0,0 +1,61 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, calendar }, options).subtract(duration1), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options).subtract(duration1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).subtract(days10), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).subtract(days10), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).subtract(days10), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-dangi.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-dangi.js new file mode 100644 index 00000000000..bbd67f392e2 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-dangi.js @@ -0,0 +1,61 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, calendar }, options).subtract(duration1), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options).subtract(duration1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).subtract(days10), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).subtract(days10), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, calendar }, options).subtract(days10), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-chinese.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-chinese.js new file mode 100644 index 00000000000..f62abb36b87 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-chinese.js @@ -0,0 +1,126 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(-1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).subtract(years1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(years1), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, calendar }, options).subtract(years1), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -3)), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1n), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 3)), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1n), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1n), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).subtract(days10), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).subtract(days10), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-dangi.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-dangi.js new file mode 100644 index 00000000000..d449ad1fcb9 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/leap-months-dangi.js @@ -0,0 +1,126 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(-1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options).subtract(years1), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(years1), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, calendar }, options).subtract(years1), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -3)), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1n), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 2)), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 3)), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1n), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, calendar }, options).subtract(months1n), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, calendar }, options).subtract(months2weeks3), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, calendar }, options).subtract(days10), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, calendar }, options).subtract(days10), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-chinese.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-chinese.js new file mode 100644 index 00000000000..e9f4bfa09cd --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-chinese.js @@ -0,0 +1,61 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(duration1).toPlainDateTime(), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(duration1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-dangi.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-dangi.js new file mode 100644 index 00000000000..5c1af6243eb --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-dangi.js @@ -0,0 +1,61 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(duration1).toPlainDateTime(), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(duration1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-chinese.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-chinese.js new file mode 100644 index 00000000000..af4c72495f4 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-chinese.js @@ -0,0 +1,126 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(years1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(years1).toPlainDateTime(), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(years1).toPlainDateTime(), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1).toPlainDateTime(), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1).toPlainDateTime(), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 3)).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(months1n).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -3)).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1n).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1n).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-dangi.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-dangi.js new file mode 100644 index 00000000000..359858820e7 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/leap-months-dangi.js @@ -0,0 +1,126 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(years1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(years1).toPlainDateTime(), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(years1).toPlainDateTime(), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1).toPlainDateTime(), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1).toPlainDateTime(), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 3)).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(months1n).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.add(new Temporal.Duration(0, -3)).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1n).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months1n).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(months2weeks3).toPlainDateTime(), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(days10).toPlainDateTime(), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-chinese.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-chinese.js new file mode 100644 index 00000000000..4e64ac4b95e --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-chinese.js @@ -0,0 +1,61 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(duration1).toPlainDateTime(), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(duration1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-dangi.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-dangi.js new file mode 100644 index 00000000000..3e840968f6a --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-dangi.js @@ -0,0 +1,61 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const duration1 = new Temporal.Duration(0, -1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M11", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(duration1).toPlainDateTime(), + 2019, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(duration1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 month, with result in next year" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 2021, 3, "M03", 22, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from non-leap day/month, ending in same year" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 2022, 3, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from end of year to next year" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 2021, 1, "M01", 11, 12, 34, 0, 0, 0, 0, "add 10 days, ending in same month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 2021, 2, "M02", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M12", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 2022, 1, "M01", 10, 12, 34, 0, 0, 0, 0, "add 10 days, ending in following year" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-chinese.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-chinese.js new file mode 100644 index 00000000000..d9470c70217 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-chinese.js @@ -0,0 +1,126 @@ +// 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 chinese calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "chinese"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(-1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(years1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(years1).toPlainDateTime(), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(years1).toPlainDateTime(), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1).toPlainDateTime(), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1).toPlainDateTime(), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -3)).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1n).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 3)).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1n).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1n).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-dangi.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-dangi.js new file mode 100644 index 00000000000..ab28a6b7639 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/leap-months-dangi.js @@ -0,0 +1,126 @@ +// 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 dangi calendar +features: [Temporal, Intl.Era-monthcode] +includes: [temporalHelpers.js] +---*/ + +const calendar = "dangi"; +const options = { overflow: "reject" }; + +// Years + +const years1 = new Temporal.Duration(-1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(years1).toPlainDateTime(), + 2020, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "add 1 year from non-leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1966, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(years1).toPlainDateTime(), + 1967, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 year from leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1938, monthCode: "M07L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(years1).toPlainDateTime(), + 1939, 7, "M07", 29, 12, 34, 0, 0, 0, 0, "add 1 year from leap day in leap month" +); + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1).toPlainDateTime(), + 1947, 4, "M03", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1).toPlainDateTime(), + 1955, 5, "M04", 1, 12, 34, 0, 0, 0, 0, "add 1 month, starting at start of leap month with 30 days" +); + +const date1 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "adding 1 month to M03 in leap year lands in M04 (not M04L)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "adding 2 months to M03 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -3)).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "adding 3 months to M03 in leap year lands in M05 (not M06)" +); + +const date2 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(months1n).toPlainDateTime(), + 2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M06 in leap year lands in M05" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 2)).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 2 months from M06 in leap year lands in M04L (leap month)" +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(new Temporal.Duration(0, 3)).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 3 months from M06 in leap year lands in M04 (not M03)" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M05", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1n).toPlainDateTime(), + 2020, 5, "M04L", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M05 in leap year lands in M04L" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M04L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months1n).toPlainDateTime(), + 2020, 4, "M04", 1, 12, 34, 0, 0, 0, 0, "Subtracting 1 month from M04L in calendar lands in M04" +); + +// Weeks + +const months2weeks3 = new Temporal.Duration(0, /* months = */ -2, /* weeks = */ -3); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1947, 6, "M05", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from last day leap month without leap day" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1955, 7, "M06", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M01", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1947, 4, "M03", 21, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M06", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(months2weeks3).toPlainDateTime(), + 1955, 10, "M09", 20, 12, 34, 0, 0, 0, 0, "add 2 months 3 weeks from immediately before a leap month" +); + +// Days + +const days10 = new Temporal.Duration(0, 0, 0, /* days = */ -10); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1955, monthCode: "M03L", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 1955, 5, "M04", 10, 12, 34, 0, 0, 0, 0, "add 10 days from leap day in leap month" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1947, monthCode: "M02L", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(days10).toPlainDateTime(), + 1947, 4, "M03", 10, 12, 34, 0, 0, 0, 0, "add 10 days from last day of leap month" +); From 28d669f5fa4af0874673878e60615960904905b1 Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Fri, 7 Nov 2025 20:40:59 -0800 Subject: [PATCH 2/7] 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 00000000000..0355907a064 --- /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 00000000000..09f460f2b9d --- /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 00000000000..78b9ee99dd7 --- /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 00000000000..a1365a78330 --- /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 00000000000..62dd3012bc2 --- /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 00000000000..42f98225096 --- /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 00000000000..119a8f99908 --- /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 00000000000..f4f99d46311 --- /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 00000000000..712f2e8ef18 --- /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 00000000000..cd6d080a86d --- /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 00000000000..8fcf47ec770 --- /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 00000000000..1a52d098121 --- /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 +); From fb09fc6cffa72f4441296e3799df58ecf4351426 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Fri, 7 Nov 2025 20:42:28 -0800 Subject: [PATCH 3/7] Intl Era Monthcode: Date addition tests for islamic calendars Co-Authored-By: Philip Chimento --- .../prototype/add/basic-islamic-civil.js | 81 +++++++++++++++++++ .../prototype/add/basic-islamic-tbla.js | 81 +++++++++++++++++++ .../prototype/add/basic-islamic-umalqura.js | 81 +++++++++++++++++++ .../add/constrain-day-islamic-civil.js | 40 +++++++++ .../add/constrain-day-islamic-tbla.js | 40 +++++++++ .../add/constrain-day-islamic-umalqura.js | 40 +++++++++ .../prototype/subtract/basic-islamic-civil.js | 81 +++++++++++++++++++ .../prototype/subtract/basic-islamic-tbla.js | 81 +++++++++++++++++++ .../subtract/basic-islamic-umalqura.js | 81 +++++++++++++++++++ .../subtract/constrain-day-islamic-civil.js | 40 +++++++++ .../subtract/constrain-day-islamic-tbla.js | 40 +++++++++ .../constrain-day-islamic-umalqura.js | 40 +++++++++ .../prototype/add/basic-islamic-civil.js | 81 +++++++++++++++++++ .../prototype/add/basic-islamic-tbla.js | 81 +++++++++++++++++++ .../prototype/add/basic-islamic-umalqura.js | 81 +++++++++++++++++++ .../add/constrain-day-islamic-civil.js | 40 +++++++++ .../add/constrain-day-islamic-tbla.js | 40 +++++++++ .../add/constrain-day-islamic-umalqura.js | 40 +++++++++ .../prototype/subtract/basic-islamic-civil.js | 81 +++++++++++++++++++ .../prototype/subtract/basic-islamic-tbla.js | 81 +++++++++++++++++++ .../subtract/basic-islamic-umalqura.js | 81 +++++++++++++++++++ .../subtract/constrain-day-islamic-civil.js | 40 +++++++++ .../subtract/constrain-day-islamic-tbla.js | 40 +++++++++ .../constrain-day-islamic-umalqura.js | 40 +++++++++ .../prototype/add/basic-islamic-civil.js | 81 +++++++++++++++++++ .../prototype/add/basic-islamic-tbla.js | 81 +++++++++++++++++++ .../prototype/add/basic-islamic-umalqura.js | 81 +++++++++++++++++++ .../add/constrain-day-islamic-civil.js | 40 +++++++++ .../add/constrain-day-islamic-tbla.js | 40 +++++++++ .../add/constrain-day-islamic-umalqura.js | 40 +++++++++ .../prototype/subtract/basic-islamic-civil.js | 81 +++++++++++++++++++ .../prototype/subtract/basic-islamic-tbla.js | 81 +++++++++++++++++++ .../subtract/basic-islamic-umalqura.js | 81 +++++++++++++++++++ .../subtract/constrain-day-islamic-civil.js | 40 +++++++++ .../subtract/constrain-day-islamic-tbla.js | 40 +++++++++ .../constrain-day-islamic-umalqura.js | 40 +++++++++ 36 files changed, 2178 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-umalqura.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-civil.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-tbla.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-umalqura.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-civil.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-tbla.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-umalqura.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-civil.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-tbla.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-umalqura.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-civil.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-tbla.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-umalqura.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-civil.js b/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-civil.js new file mode 100644 index 00000000000..1667b3ea2ec --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-civil.js @@ -0,0 +1,81 @@ +// 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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 8)), + 1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 11)), + 1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 12)), + 1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).add(new Temporal.Duration(0, 13)), + 1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).add(new Temporal.Duration(0, 6)), + 1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).add(new Temporal.Duration(0, 5)), + 1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).add(new Temporal.Duration(0, 100)), + 1408, 5, "M05", 1, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).add(new Temporal.Duration(0, -8)), + 1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).add(new Temporal.Duration(0, -12)), + 1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).add(new Temporal.Duration(0, -5)), + 1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-tbla.js b/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-tbla.js new file mode 100644 index 00000000000..190967cb7b2 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-tbla.js @@ -0,0 +1,81 @@ +// 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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 8)), + 1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 11)), + 1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 12)), + 1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).add(new Temporal.Duration(0, 13)), + 1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).add(new Temporal.Duration(0, 6)), + 1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).add(new Temporal.Duration(0, 5)), + 1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).add(new Temporal.Duration(0, 100)), + 1408, 5, "M05", 1, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).add(new Temporal.Duration(0, -8)), + 1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).add(new Temporal.Duration(0, -12)), + 1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).add(new Temporal.Duration(0, -5)), + 1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-umalqura.js b/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-umalqura.js new file mode 100644 index 00000000000..58a84638e23 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/basic-islamic-umalqura.js @@ -0,0 +1,81 @@ +// 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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 8)), + 1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 11)), + 1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(0, 12)), + 1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).add(new Temporal.Duration(0, 13)), + 1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).add(new Temporal.Duration(0, 6)), + 1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).add(new Temporal.Duration(0, 5)), + 1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).add(new Temporal.Duration(0, 100)), + 1408, 5, "M05", 1, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).add(new Temporal.Duration(0, -8)), + 1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).add(new Temporal.Duration(0, -12)), + 1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).add(new Temporal.Duration(0, -5)), + 1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-civil.js b/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-civil.js new file mode 100644 index 00000000000..2e1a7f21485 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-civil.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 30, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(months1), + 1445, 2, "M02", 29, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDate( + date1.add(months1n), + 1444, 12, "M12", 29, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-tbla.js b/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-tbla.js new file mode 100644 index 00000000000..cbaa299c264 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-tbla.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 30, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(months1), + 1445, 2, "M02", 29, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDate( + date1.add(months1n), + 1444, 12, "M12", 29, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-umalqura.js b/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-umalqura.js new file mode 100644 index 00000000000..3a10b55d83f --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/constrain-day-islamic-umalqura.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, /* months = */ 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.PlainDate.from({ year: 1447, monthCode: "M01", day: 30, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(months1), + 1447, 2, "M02", 29, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1447 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDate( + date1.add(months1n), + 1446, 12, "M12", 29, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1446 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-civil.js b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-civil.js new file mode 100644 index 00000000000..2fadcb8f35f --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-civil.js @@ -0,0 +1,81 @@ +// 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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -8)), + 1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -11)), + 1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -12)), + 1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).subtract(new Temporal.Duration(0, -13)), + 1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).subtract(new Temporal.Duration(0, -6)), + 1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).subtract(new Temporal.Duration(0, -5)), + 1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).subtract(new Temporal.Duration(0, -100)), + 1408, 5, "M05", 1, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).subtract(new Temporal.Duration(0, 8)), + 1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).subtract(new Temporal.Duration(0, 12)), + 1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).subtract(new Temporal.Duration(0, 5)), + 1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-tbla.js b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-tbla.js new file mode 100644 index 00000000000..9dc59acb3bb --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-tbla.js @@ -0,0 +1,81 @@ +// 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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -8)), + 1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -11)), + 1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -12)), + 1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).subtract(new Temporal.Duration(0, -13)), + 1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).subtract(new Temporal.Duration(0, -6)), + 1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).subtract(new Temporal.Duration(0, -5)), + 1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).subtract(new Temporal.Duration(0, -100)), + 1408, 5, "M05", 1, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).subtract(new Temporal.Duration(0, 8)), + 1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).subtract(new Temporal.Duration(0, 12)), + 1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).subtract(new Temporal.Duration(0, 5)), + 1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-umalqura.js b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-umalqura.js new file mode 100644 index 00000000000..b19121812ab --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/basic-islamic-umalqura.js @@ -0,0 +1,81 @@ +// 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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -8)), + 1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -11)), + 1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(0, -12)), + 1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).subtract(new Temporal.Duration(0, -13)), + 1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).subtract(new Temporal.Duration(0, -6)), + 1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).subtract(new Temporal.Duration(0, -5)), + 1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).subtract(new Temporal.Duration(0, -100)), + 1408, 5, "M05", 1, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).subtract(new Temporal.Duration(0, 8)), + 1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).subtract(new Temporal.Duration(0, 12)), + 1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).subtract(new Temporal.Duration(0, 5)), + 1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-civil.js b/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-civil.js new file mode 100644 index 00000000000..64e316e3c23 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-civil.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 30, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(months1), + 1445, 2, "M02", 29, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDate( + date1.subtract(months1n), + 1444, 12, "M12", 29, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-tbla.js b/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-tbla.js new file mode 100644 index 00000000000..2eb6f7296fe --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-tbla.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 30, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(months1), + 1445, 2, "M02", 29, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDate( + date1.subtract(months1n), + 1444, 12, "M12", 29, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-umalqura.js b/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-umalqura.js new file mode 100644 index 00000000000..624660e38fc --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/constrain-day-islamic-umalqura.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, /* months = */ -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.PlainDate.from({ year: 1447, monthCode: "M01", day: 30, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(months1), + 1447, 2, "M02", 29, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1447 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDate( + date1.subtract(months1n), + 1446, 12, "M12", 29, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1446 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-civil.js b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-civil.js new file mode 100644 index 00000000000..8822bd85593 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-civil.js @@ -0,0 +1,81 @@ +// 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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 8)), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 11)), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 12)), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 13)), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, 6)), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 5)), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 100)), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -8)), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -12)), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -5)), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-tbla.js b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-tbla.js new file mode 100644 index 00000000000..75b5aebf6b9 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-tbla.js @@ -0,0 +1,81 @@ +// 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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 8)), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 11)), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 12)), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 13)), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, 6)), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 5)), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 100)), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -8)), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -12)), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -5)), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-umalqura.js b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-umalqura.js new file mode 100644 index 00000000000..780a836529a --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/basic-islamic-umalqura.js @@ -0,0 +1,81 @@ +// 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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 8)), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 11)), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 12)), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 13)), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, 6)), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 5)), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }).add(new Temporal.Duration(0, 100)), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -8)), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -12)), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, calendar }, options).add(new Temporal.Duration(0, -5)), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-civil.js b/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-civil.js new file mode 100644 index 00000000000..ed43c1b99ea --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-civil.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.add(months1n), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-tbla.js b/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-tbla.js new file mode 100644 index 00000000000..28ff8b080ad --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-tbla.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.add(months1n), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-umalqura.js b/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-umalqura.js new file mode 100644 index 00000000000..31557acaa7e --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/constrain-day-islamic-umalqura.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, /* months = */ 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.PlainDateTime.from({ year: 1447, monthCode: "M01", day: 30, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1), + 1447, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1447 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.add(months1n), + 1446, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1446 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-civil.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-civil.js new file mode 100644 index 00000000000..a9be532fcbe --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-civil.js @@ -0,0 +1,81 @@ +// 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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -8)), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -11)), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -12)), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -13)), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, -6)), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -5)), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -100)), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 8)), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 12)), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 5)), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-tbla.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-tbla.js new file mode 100644 index 00000000000..102e87589a9 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-tbla.js @@ -0,0 +1,81 @@ +// 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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -8)), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -11)), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -12)), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -13)), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, -6)), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -5)), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -100)), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 8)), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 12)), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 5)), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-umalqura.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-umalqura.js new file mode 100644 index 00000000000..3c637e9a8a9 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/basic-islamic-umalqura.js @@ -0,0 +1,81 @@ +// 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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -8)), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -11)), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -12)), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -13)), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, -6)), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -5)), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }).subtract(new Temporal.Duration(0, -100)), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 8)), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 12)), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, calendar }, options).subtract(new Temporal.Duration(0, 5)), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-civil.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-civil.js new file mode 100644 index 00000000000..33769f1e38c --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-civil.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1n), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-tbla.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-tbla.js new file mode 100644 index 00000000000..3daf60f3464 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-tbla.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.PlainDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1n), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-umalqura.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-umalqura.js new file mode 100644 index 00000000000..7d76a8a8741 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/constrain-day-islamic-umalqura.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, /* months = */ -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.PlainDateTime.from({ year: 1447, monthCode: "M01", day: 30, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1), + 1447, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1447 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1n), + 1446, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1446 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-civil.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-civil.js new file mode 100644 index 00000000000..f9275dcbf4d --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-civil.js @@ -0,0 +1,81 @@ +// 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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 8)).toPlainDateTime(), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 11)).toPlainDateTime(), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 12)).toPlainDateTime(), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 13)).toPlainDateTime(), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, 6)).toPlainDateTime(), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 5)).toPlainDateTime(), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 100)).toPlainDateTime(), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -8)).toPlainDateTime(), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -12)).toPlainDateTime(), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -5)).toPlainDateTime(), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-tbla.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-tbla.js new file mode 100644 index 00000000000..bc7d19b763e --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-tbla.js @@ -0,0 +1,81 @@ +// 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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 8)).toPlainDateTime(), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 11)).toPlainDateTime(), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 12)).toPlainDateTime(), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 13)).toPlainDateTime(), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, 6)).toPlainDateTime(), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 5)).toPlainDateTime(), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 100)).toPlainDateTime(), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -8)).toPlainDateTime(), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -12)).toPlainDateTime(), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -5)).toPlainDateTime(), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-umalqura.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-umalqura.js new file mode 100644 index 00000000000..88cb011179f --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/basic-islamic-umalqura.js @@ -0,0 +1,81 @@ +// 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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 8)).toPlainDateTime(), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 11)).toPlainDateTime(), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(0, 12)).toPlainDateTime(), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 13)).toPlainDateTime(), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, 6)).toPlainDateTime(), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 5)).toPlainDateTime(), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).add(new Temporal.Duration(0, 100)).toPlainDateTime(), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -8)).toPlainDateTime(), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -12)).toPlainDateTime(), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).add(new Temporal.Duration(0, -5)).toPlainDateTime(), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-civil.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-civil.js new file mode 100644 index 00000000000..d9d2e9272bb --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-civil.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1).toPlainDateTime(), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.add(months1n).toPlainDateTime(), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-tbla.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-tbla.js new file mode 100644 index 00000000000..be3e7e957d1 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-tbla.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1).toPlainDateTime(), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.add(months1n).toPlainDateTime(), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-umalqura.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-umalqura.js new file mode 100644 index 00000000000..8cc1b064594 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/constrain-day-islamic-umalqura.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, /* months = */ 1); +const months1n = new Temporal.Duration(0, -1); + +const date1 = Temporal.ZonedDateTime.from({ year: 1447, monthCode: "M01", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(months1).toPlainDateTime(), + 1447, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1447 +); + +assert.throws(RangeError, function () { + date1.add(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.add(months1n).toPlainDateTime(), + 1446, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1446 +); + +assert.throws(RangeError, function () { + date1.add(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-civil.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-civil.js new file mode 100644 index 00000000000..526e5516d17 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-civil.js @@ -0,0 +1,81 @@ +// 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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -8)).toPlainDateTime(), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -11)).toPlainDateTime(), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -12)).toPlainDateTime(), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -13)).toPlainDateTime(), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, -6)).toPlainDateTime(), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -5)).toPlainDateTime(), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -100)).toPlainDateTime(), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 8)).toPlainDateTime(), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 12)).toPlainDateTime(), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 5)).toPlainDateTime(), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-tbla.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-tbla.js new file mode 100644 index 00000000000..0a89c918459 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-tbla.js @@ -0,0 +1,81 @@ +// 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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -8)).toPlainDateTime(), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -11)).toPlainDateTime(), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -12)).toPlainDateTime(), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -13)).toPlainDateTime(), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, -6)).toPlainDateTime(), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -5)).toPlainDateTime(), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -100)).toPlainDateTime(), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 8)).toPlainDateTime(), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 12)).toPlainDateTime(), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 5)).toPlainDateTime(), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-umalqura.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-umalqura.js new file mode 100644 index 00000000000..d44a78b3fb5 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/basic-islamic-umalqura.js @@ -0,0 +1,81 @@ +// 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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -8)).toPlainDateTime(), + 1445, 9, "M09", 1, 12, 34, 0, 0, 0, 0, "Adding 8 months to Muharram 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -11)).toPlainDateTime(), + 1445, 12, "M12", 1, 12, 34, 0, 0, 0, 0, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(0, -12)).toPlainDateTime(), + 1446, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 12 months to Muharram 1445 lands in Muharram 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -13)).toPlainDateTime(), + 1446, 7, "M07", 15, 12, 34, 0, 0, 0, 0, "Adding 13 months to Jumada II 1445 lands in Rajab 1446", + "ah", 1446 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, -6)).toPlainDateTime(), + 1445, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Adding 6 months to Rabi I 1445 lands in Ramadan", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1444, monthCode: "M10", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -5)).toPlainDateTime(), + 1445, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 5 months to Shawwal 1444 crosses to 1445", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1400, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }).subtract(new Temporal.Duration(0, -100)).toPlainDateTime(), + 1408, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "Adding a large number of months", + "ah", 1408 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M09", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 8)).toPlainDateTime(), + 1445, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 8 months from Ramadan 1445 lands in Muharram", + "ah", 1445 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 12)).toPlainDateTime(), + 1444, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444", + "ah", 1444 +); + +TemporalHelpers.assertPlainDateTime( + Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M02", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options).subtract(new Temporal.Duration(0, 5)).toPlainDateTime(), + 1444, 9, "M09", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444", + "ah", 1444 +); + +// Weeks + +// Days diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-civil.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-civil.js new file mode 100644 index 00000000000..63c5c718d08 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-civil.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1).toPlainDateTime(), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1n).toPlainDateTime(), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-tbla.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-tbla.js new file mode 100644 index 00000000000..04e5f92588d --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-tbla.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.ZonedDateTime.from({ year: 1445, monthCode: "M01", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1).toPlainDateTime(), + 1445, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1445 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1n).toPlainDateTime(), + 1444, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1444 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-umalqura.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-umalqura.js new file mode 100644 index 00000000000..fa75fb03343 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/constrain-day-islamic-umalqura.js @@ -0,0 +1,40 @@ +// 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: Constraining the day for 29/30-day months in islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +// Years + +// Months + +const months1 = new Temporal.Duration(0, /* months = */ -1); +const months1n = new Temporal.Duration(0, 1); + +const date1 = Temporal.ZonedDateTime.from({ year: 1447, monthCode: "M01", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1).toPlainDateTime(), + 1447, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when adding months to a 30-day month and landing in a 29-day month", + "ah", 1447 +); + +assert.throws(RangeError, function () { + date1.subtract(months1, options); +}, "Adding months to a 30-day month and landing in a 29-day month rejects"); + +TemporalHelpers.assertPlainDateTime( + date1.subtract(months1n).toPlainDateTime(), + 1446, 12, "M12", 29, 12, 34, 0, 0, 0, 0, "Day is constrained when subtracting months from a 30-day month and landing in a 29-day month", + "ah", 1446 +); + +assert.throws(RangeError, function () { + date1.subtract(months1n, options); +}, "Subtracting months from a 30-day month and landing in a 29-day month rejects"); From 215c4f4c6a4b56212bebde7319f70a1498896d15 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Fri, 7 Nov 2025 20:43:24 -0800 Subject: [PATCH 4/7] Intl Era Monthcode: Era boundary tests for ethiopic calendar Co-Authored-By: Philip Chimento --- .../prototype/add/era-boundary-ethiopic.js | 48 +++++++++++++++++++ .../subtract/era-boundary-ethiopic.js | 48 +++++++++++++++++++ .../prototype/add/era-boundary-ethiopic.js | 48 +++++++++++++++++++ .../subtract/era-boundary-ethiopic.js | 48 +++++++++++++++++++ .../prototype/add/era-boundary-ethiopic.js | 48 +++++++++++++++++++ .../subtract/era-boundary-ethiopic.js | 48 +++++++++++++++++++ 6 files changed, 288 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/era-boundary-ethiopic.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-ethiopic.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-ethiopic.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-ethiopic.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-ethiopic.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-ethiopic.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-ethiopic.js b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-ethiopic.js new file mode 100644 index 00000000000..e497836e098 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-ethiopic.js @@ -0,0 +1,48 @@ +// 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: Adding years works correctly across era boundaries in ethiopic calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration5 = new Temporal.Duration(5); +const duration5n = new Temporal.Duration(-5); +const calendar = "ethiopic"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(new Temporal.Duration(1)), + 1, 1, "M01", 1, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era", + "am", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(duration5), + 2005, 6, "M06", 15, "Adding 5 years within incarnation era", + "am", 2005 +); + +const date3 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(duration5), + -45, 7, "M07", 12, "Adding 5 years within Amete Alem era", + "aa", 5455 +); + +TemporalHelpers.assertPlainDate( + date2.add(duration5n), + 1995, 6, "M06", 15, "Subtracting 5 years within incarnation era", + "am", 1995 +); + +const date4 = Temporal.PlainDate.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.add(duration5n), + 0, 1, "M01", 1, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0", + "aa", 5500 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-ethiopic.js b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-ethiopic.js new file mode 100644 index 00000000000..4913c1fb2de --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-ethiopic.js @@ -0,0 +1,48 @@ +// 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: Adding years works correctly across era boundaries in ethiopic calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration5 = new Temporal.Duration(-5); +const duration5n = new Temporal.Duration(5); +const calendar = "ethiopic"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(new Temporal.Duration(-1)), + 1, 1, "M01", 1, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era", + "am", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(duration5), + 2005, 6, "M06", 15, "Adding 5 years within incarnation era", + "am", 2005 +); + +const date3 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(duration5), + -45, 7, "M07", 12, "Adding 5 years within Amete Alem era", + "aa", 5455 +); + +TemporalHelpers.assertPlainDate( + date2.subtract(duration5n), + 1995, 6, "M06", 15, "Subtracting 5 years within incarnation era", + "am", 1995 +); + +const date4 = Temporal.PlainDate.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.subtract(duration5n), + 0, 1, "M01", 1, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0", + "aa", 5500 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-ethiopic.js b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-ethiopic.js new file mode 100644 index 00000000000..79a85226b3d --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-ethiopic.js @@ -0,0 +1,48 @@ +// 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: Adding years works correctly across era boundaries in ethiopic calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration5 = new Temporal.Duration(5); +const duration5n = new Temporal.Duration(-5); +const calendar = "ethiopic"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(1)), + 1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era", + "am", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration5), + 2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era", + "am", 2005 +); + +const date3 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration5), + -45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era", + "aa", 5455 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration5n), + 1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era", + "am", 1995 +); + +const date4 = Temporal.PlainDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(duration5n), + 0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0", + "aa", 5500 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-ethiopic.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-ethiopic.js new file mode 100644 index 00000000000..87de8c33cf9 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-ethiopic.js @@ -0,0 +1,48 @@ +// 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: Adding years works correctly across era boundaries in ethiopic calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration5 = new Temporal.Duration(-5); +const duration5n = new Temporal.Duration(5); +const calendar = "ethiopic"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(-1)), + 1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era", + "am", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration5), + 2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era", + "am", 2005 +); + +const date3 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration5), + -45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era", + "aa", 5455 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration5n), + 1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era", + "am", 1995 +); + +const date4 = Temporal.PlainDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(duration5n), + 0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0", + "aa", 5500 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-ethiopic.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-ethiopic.js new file mode 100644 index 00000000000..cdfd95fc91e --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-ethiopic.js @@ -0,0 +1,48 @@ +// 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: Adding years works correctly across era boundaries in ethiopic calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration5 = new Temporal.Duration(5); +const duration5n = new Temporal.Duration(-5); +const calendar = "ethiopic"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(new Temporal.Duration(1)).toPlainDateTime(), + 1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era", + "am", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration5).toPlainDateTime(), + 2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era", + "am", 2005 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration5).toPlainDateTime(), + -45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era", + "aa", 5455 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration5n).toPlainDateTime(), + 1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era", + "am", 1995 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(duration5n).toPlainDateTime(), + 0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0", + "aa", 5500 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-ethiopic.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-ethiopic.js new file mode 100644 index 00000000000..a16965e1e2c --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-ethiopic.js @@ -0,0 +1,48 @@ +// 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: Adding years works correctly across era boundaries in ethiopic calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration5 = new Temporal.Duration(-5); +const duration5n = new Temporal.Duration(5); +const calendar = "ethiopic"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(new Temporal.Duration(-1)).toPlainDateTime(), + 1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era", + "am", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration5).toPlainDateTime(), + 2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era", + "am", 2005 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration5).toPlainDateTime(), + -45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era", + "aa", 5455 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration5n).toPlainDateTime(), + 1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era", + "am", 1995 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(duration5n).toPlainDateTime(), + 0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0", + "aa", 5500 +); From ca40d3441336e11fb791bba66d99445d789db98a Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Fri, 7 Nov 2025 20:43:42 -0800 Subject: [PATCH 5/7] Intl Era Monthcode: Era boundary tests for gregory calendar Co-Authored-By: Philip Chimento --- .../prototype/add/era-boundary-gregory.js | 68 +++++++++++++++++++ .../subtract/era-boundary-gregory.js | 68 +++++++++++++++++++ .../prototype/add/era-boundary-gregory.js | 68 +++++++++++++++++++ .../subtract/era-boundary-gregory.js | 68 +++++++++++++++++++ .../prototype/add/era-boundary-gregory.js | 68 +++++++++++++++++++ .../subtract/era-boundary-gregory.js | 68 +++++++++++++++++++ 6 files changed, 408 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/era-boundary-gregory.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-gregory.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-gregory.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-gregory.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-gregory.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-gregory.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-gregory.js b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-gregory.js new file mode 100644 index 00000000000..a78bb7445cb --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-gregory.js @@ -0,0 +1,68 @@ +// 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: Adding years works correctly across era boundaries in gregory calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "gregory"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bce", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BCE lands in 1 BCE (counts backwards)", + "bce", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bce", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BCE lands in 1 CE (no year zero)", + "ce", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ce", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 CE lands in 2 CE", + "ce", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bce", eraYear: 5, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.add(new Temporal.Duration(10)), + 6, 3, "M03", 1, "Adding 10 years to 5 BCE lands in 6 CE (no year zero)", + "ce", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ce", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.add(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 CE lands in 1 CE", + "ce", 1 +); + +TemporalHelpers.assertPlainDate( + date3.add(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 CE lands in 1 BCE", + "bce", 1 +); + +TemporalHelpers.assertPlainDate( + date2.add(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BCE lands in 2 BCE", + "bce", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ce", eraYear: 5, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date6.add(new Temporal.Duration(-10)), + -5, 3, "M03", 1, "Subtracting 10 years from 5 CE lands in 6 BCE", + "bce", 6 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-gregory.js b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-gregory.js new file mode 100644 index 00000000000..aa2d1c12890 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-gregory.js @@ -0,0 +1,68 @@ +// 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: Adding years works correctly across era boundaries in gregory calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "gregory"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bce", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BCE lands in 1 BCE (counts backwards)", + "bce", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bce", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BCE lands in 1 CE (no year zero)", + "ce", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ce", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 CE lands in 2 CE", + "ce", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bce", eraYear: 5, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.subtract(new Temporal.Duration(-10)), + 6, 3, "M03", 1, "Adding 10 years to 5 BCE lands in 6 CE (no year zero)", + "ce", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ce", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.subtract(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 CE lands in 1 CE", + "ce", 1 +); + +TemporalHelpers.assertPlainDate( + date3.subtract(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 CE lands in 1 BCE", + "bce", 1 +); + +TemporalHelpers.assertPlainDate( + date2.subtract(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BCE lands in 2 BCE", + "bce", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ce", eraYear: 5, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date6.subtract(new Temporal.Duration(10)), + -5, 3, "M03", 1, "Subtracting 10 years from 5 CE lands in 6 BCE", + "bce", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-gregory.js b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-gregory.js new file mode 100644 index 00000000000..bd3466d1d6b --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-gregory.js @@ -0,0 +1,68 @@ +// 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: Adding years works correctly across era boundaries in gregory calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "gregory"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(duration1), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BCE lands in 1 BCE (counts backwards)", + "bce", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration1), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BCE lands in 1 CE (no year zero)", + "ce", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration1), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 CE lands in 2 CE", + "ce", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(new Temporal.Duration(10)), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BCE lands in 6 CE (no year zero)", + "ce", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.add(duration1n), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 2 CE lands in 1 CE", + "ce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 CE lands in 1 BCE", + "bce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BCE lands in 2 BCE", + "bce", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.add(new Temporal.Duration(-10)), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 10 years from 5 CE lands in 6 BCE", + "bce", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-gregory.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-gregory.js new file mode 100644 index 00000000000..b0c9ed483eb --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-gregory.js @@ -0,0 +1,68 @@ +// 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: Adding years works correctly across era boundaries in gregory calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "gregory"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(duration1), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BCE lands in 1 BCE (counts backwards)", + "bce", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BCE lands in 1 CE (no year zero)", + "ce", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 CE lands in 2 CE", + "ce", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(new Temporal.Duration(-10)), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BCE lands in 6 CE (no year zero)", + "ce", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.subtract(duration1n), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 2 CE lands in 1 CE", + "ce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 CE lands in 1 BCE", + "bce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BCE lands in 2 BCE", + "bce", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.subtract(new Temporal.Duration(10)), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 10 years from 5 CE lands in 6 BCE", + "bce", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-gregory.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-gregory.js new file mode 100644 index 00000000000..6acccf5fcc2 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-gregory.js @@ -0,0 +1,68 @@ +// 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: Adding years works correctly across era boundaries in gregory calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "gregory"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(duration1).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BCE lands in 1 BCE (counts backwards)", + "bce", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration1).toPlainDateTime(), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BCE lands in 1 CE (no year zero)", + "ce", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration1).toPlainDateTime(), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 CE lands in 2 CE", + "ce", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(new Temporal.Duration(10)).toPlainDateTime(), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BCE lands in 6 CE (no year zero)", + "ce", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.add(duration1n).toPlainDateTime(), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 2 CE lands in 1 CE", + "ce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 CE lands in 1 BCE", + "bce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BCE lands in 2 BCE", + "bce", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.add(new Temporal.Duration(-10)).toPlainDateTime(), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 10 years from 5 CE lands in 6 BCE", + "bce", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-gregory.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-gregory.js new file mode 100644 index 00000000000..4b5af766d65 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-gregory.js @@ -0,0 +1,68 @@ +// 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: Adding years works correctly across era boundaries in gregory calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "gregory"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(duration1).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BCE lands in 1 BCE (counts backwards)", + "bce", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1).toPlainDateTime(), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BCE lands in 1 CE (no year zero)", + "ce", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ce", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1).toPlainDateTime(), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 CE lands in 2 CE", + "ce", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(new Temporal.Duration(-10)).toPlainDateTime(), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BCE lands in 6 CE (no year zero)", + "ce", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ce", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.subtract(duration1n).toPlainDateTime(), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 2 CE lands in 1 CE", + "ce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 CE lands in 1 BCE", + "bce", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BCE lands in 2 BCE", + "bce", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ce", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.subtract(new Temporal.Duration(10)).toPlainDateTime(), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 10 years from 5 CE lands in 6 BCE", + "bce", 6 +); From 6a7f6f4d30cc7da0b0d4ed25073339dd43ad5407 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Fri, 7 Nov 2025 20:44:03 -0800 Subject: [PATCH 6/7] Intl Era Monthcode: Era boundary tests for japanese calendar Co-Authored-By: Philip Chimento --- .../prototype/add/era-boundary-japanese.js | 81 +++++++++++++++++++ .../subtract/era-boundary-japanese.js | 81 +++++++++++++++++++ .../prototype/add/era-boundary-japanese.js | 81 +++++++++++++++++++ .../subtract/era-boundary-japanese.js | 81 +++++++++++++++++++ .../prototype/add/era-boundary-japanese.js | 81 +++++++++++++++++++ .../subtract/era-boundary-japanese.js | 81 +++++++++++++++++++ 6 files changed, 486 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/era-boundary-japanese.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-japanese.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-japanese.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-japanese.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-japanese.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-japanese.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-japanese.js b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-japanese.js new file mode 100644 index 00000000000..9513d37fc1f --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-japanese.js @@ -0,0 +1,81 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Reiwa era started on May 1, 2019 (Reiwa 1 = 2019) +// Heisei era: 1989-2019 (Heisei 31 ended April 30, 2019) + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "japanese"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "heisei", eraYear: 30, monthCode: "M03", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(duration1), + 2019, 3, "M03", 15, "Adding 1 year to Heisei 30 March (before May 1) lands in Heisei 31 March", + "heisei", 31 +); + +const date2 = Temporal.PlainDate.from({ era: "heisei", eraYear: 31, monthCode: "M04", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(duration1), + 2020, 4, "M04", 15, "Adding 1 year to Heisei 31 April (before May 1) lands in Reiwa 2 April", + "reiwa", 2 +); + +const date3 = Temporal.PlainDate.from({ era: "heisei", eraYear: 30, monthCode: "M06", day: 12, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(duration1), + 2019, 6, "M06", 12, "Adding 1 year to Heisei 30 June (after May 1) lands in Reiwa 1 June", + "reiwa", 1 +); + +const date4 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 1, monthCode: "M06", day: 10, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.add(duration1), + 2020, 6, "M06", 10, "Adding 1 year to Reiwa 1 June lands in Reiwa 2 June", + "reiwa", 2 +); + +const date5 = Temporal.PlainDate.from({ era: "heisei", eraYear: 28, monthCode: "M07", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.add(new Temporal.Duration(3)), + 2019, 7, "M07", 1, "Multiple years across era boundary: Adding 3 years to Heisei 28 July lands in Reiwa 1 July", + "reiwa", 1 +); + +const date6 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date6.add(duration1n), + 2019, 6, "M06", 15, "Subtracting 1 year from Reiwa 2 June lands in Reiwa 1 June", + "reiwa", 1 +); + +const date7 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 2, monthCode: "M03", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date7.add(duration1n), + 2019, 3, "M03", 15, "Subtracting 1 year from Reiwa 2 March lands in Heisei 31 March", + "heisei", 31 +); + +const date8 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 1, monthCode: "M07", day: 10, calendar }, options); +TemporalHelpers.assertPlainDate( + date8.add(duration1n), + 2018, 7, "M07", 10, "Subtracting 1 year from Reiwa 1 July lands in Heisei 30 July", + "heisei", 30 +); + +const date9 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 4, monthCode: "M02", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date9.add(new Temporal.Duration(-5)), + 2017, 2, "M02", 1, "Subtracting 5 years from Reiwa 4 February lands in Heisei 29 February", + "heisei", 29 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-japanese.js b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-japanese.js new file mode 100644 index 00000000000..301d7d1d1c8 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-japanese.js @@ -0,0 +1,81 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Reiwa era started on May 1, 2019 (Reiwa 1 = 2019) +// Heisei era: 1989-2019 (Heisei 31 ended April 30, 2019) + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "japanese"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "heisei", eraYear: 30, monthCode: "M03", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(duration1), + 2019, 3, "M03", 15, "Adding 1 year to Heisei 30 March (before May 1) lands in Heisei 31 March", + "heisei", 31 +); + +const date2 = Temporal.PlainDate.from({ era: "heisei", eraYear: 31, monthCode: "M04", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(duration1), + 2020, 4, "M04", 15, "Adding 1 year to Heisei 31 April (before May 1) lands in Reiwa 2 April", + "reiwa", 2 +); + +const date3 = Temporal.PlainDate.from({ era: "heisei", eraYear: 30, monthCode: "M06", day: 12, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(duration1), + 2019, 6, "M06", 12, "Adding 1 year to Heisei 30 June (after May 1) lands in Reiwa 1 June", + "reiwa", 1 +); + +const date4 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 1, monthCode: "M06", day: 10, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.subtract(duration1), + 2020, 6, "M06", 10, "Adding 1 year to Reiwa 1 June lands in Reiwa 2 June", + "reiwa", 2 +); + +const date5 = Temporal.PlainDate.from({ era: "heisei", eraYear: 28, monthCode: "M07", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.subtract(new Temporal.Duration(-3)), + 2019, 7, "M07", 1, "Multiple years across era boundary: Adding 3 years to Heisei 28 July lands in Reiwa 1 July", + "reiwa", 1 +); + +const date6 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date6.subtract(duration1n), + 2019, 6, "M06", 15, "Subtracting 1 year from Reiwa 2 June lands in Reiwa 1 June", + "reiwa", 1 +); + +const date7 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 2, monthCode: "M03", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date7.subtract(duration1n), + 2019, 3, "M03", 15, "Subtracting 1 year from Reiwa 2 March lands in Heisei 31 March", + "heisei", 31 +); + +const date8 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 1, monthCode: "M07", day: 10, calendar }, options); +TemporalHelpers.assertPlainDate( + date8.subtract(duration1n), + 2018, 7, "M07", 10, "Subtracting 1 year from Reiwa 1 July lands in Heisei 30 July", + "heisei", 30 +); + +const date9 = Temporal.PlainDate.from({ era: "reiwa", eraYear: 4, monthCode: "M02", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date9.subtract(new Temporal.Duration(5)), + 2017, 2, "M02", 1, "Subtracting 5 years from Reiwa 4 February lands in Heisei 29 February", + "heisei", 29 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-japanese.js b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-japanese.js new file mode 100644 index 00000000000..1922d6bf550 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-japanese.js @@ -0,0 +1,81 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Reiwa era started on May 1, 2019 (Reiwa 1 = 2019) +// Heisei era: 1989-2019 (Heisei 31 ended April 30, 2019) + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "japanese"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(duration1), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 March (before May 1) lands in Heisei 31 March", + "heisei", 31 +); + +const date2 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 31, monthCode: "M04", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration1), + 2020, 4, "M04", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 31 April (before May 1) lands in Reiwa 2 April", + "reiwa", 2 +); + +const date3 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M06", day: 12, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration1), + 2019, 6, "M06", 12, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 June (after May 1) lands in Reiwa 1 June", + "reiwa", 1 +); + +const date4 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M06", day: 10, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(duration1), + 2020, 6, "M06", 10, 12, 34, 0, 0, 0, 0, "Adding 1 year to Reiwa 1 June lands in Reiwa 2 June", + "reiwa", 2 +); + +const date5 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 28, monthCode: "M07", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.add(new Temporal.Duration(3)), + 2019, 7, "M07", 1, 12, 34, 0, 0, 0, 0, "Multiple years across era boundary: Adding 3 years to Heisei 28 July lands in Reiwa 1 July", + "reiwa", 1 +); + +const date6 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.add(duration1n), + 2019, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 June lands in Reiwa 1 June", + "reiwa", 1 +); + +const date7 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date7.add(duration1n), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 March lands in Heisei 31 March", + "heisei", 31 +); + +const date8 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M07", day: 10, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date8.add(duration1n), + 2018, 7, "M07", 10, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 1 July lands in Heisei 30 July", + "heisei", 30 +); + +const date9 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 4, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date9.add(new Temporal.Duration(-5)), + 2017, 2, "M02", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from Reiwa 4 February lands in Heisei 29 February", + "heisei", 29 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-japanese.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-japanese.js new file mode 100644 index 00000000000..ee13d1a5c37 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-japanese.js @@ -0,0 +1,81 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Reiwa era started on May 1, 2019 (Reiwa 1 = 2019) +// Heisei era: 1989-2019 (Heisei 31 ended April 30, 2019) + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "japanese"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(duration1), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 March (before May 1) lands in Heisei 31 March", + "heisei", 31 +); + +const date2 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 31, monthCode: "M04", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1), + 2020, 4, "M04", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 31 April (before May 1) lands in Reiwa 2 April", + "reiwa", 2 +); + +const date3 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M06", day: 12, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1), + 2019, 6, "M06", 12, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 June (after May 1) lands in Reiwa 1 June", + "reiwa", 1 +); + +const date4 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M06", day: 10, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(duration1), + 2020, 6, "M06", 10, 12, 34, 0, 0, 0, 0, "Adding 1 year to Reiwa 1 June lands in Reiwa 2 June", + "reiwa", 2 +); + +const date5 = Temporal.PlainDateTime.from({ era: "heisei", eraYear: 28, monthCode: "M07", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.subtract(new Temporal.Duration(-3)), + 2019, 7, "M07", 1, 12, 34, 0, 0, 0, 0, "Multiple years across era boundary: Adding 3 years to Heisei 28 July lands in Reiwa 1 July", + "reiwa", 1 +); + +const date6 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.subtract(duration1n), + 2019, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 June lands in Reiwa 1 June", + "reiwa", 1 +); + +const date7 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date7.subtract(duration1n), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 March lands in Heisei 31 March", + "heisei", 31 +); + +const date8 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M07", day: 10, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date8.subtract(duration1n), + 2018, 7, "M07", 10, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 1 July lands in Heisei 30 July", + "heisei", 30 +); + +const date9 = Temporal.PlainDateTime.from({ era: "reiwa", eraYear: 4, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date9.subtract(new Temporal.Duration(5)), + 2017, 2, "M02", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from Reiwa 4 February lands in Heisei 29 February", + "heisei", 29 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-japanese.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-japanese.js new file mode 100644 index 00000000000..1ba8e2ea4af --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-japanese.js @@ -0,0 +1,81 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Reiwa era started on May 1, 2019 (Reiwa 1 = 2019) +// Heisei era: 1989-2019 (Heisei 31 ended April 30, 2019) + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "japanese"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(duration1).toPlainDateTime(), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 March (before May 1) lands in Heisei 31 March", + "heisei", 31 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 31, monthCode: "M04", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration1).toPlainDateTime(), + 2020, 4, "M04", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 31 April (before May 1) lands in Reiwa 2 April", + "reiwa", 2 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M06", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration1).toPlainDateTime(), + 2019, 6, "M06", 12, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 June (after May 1) lands in Reiwa 1 June", + "reiwa", 1 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M06", day: 10, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(duration1).toPlainDateTime(), + 2020, 6, "M06", 10, 12, 34, 0, 0, 0, 0, "Adding 1 year to Reiwa 1 June lands in Reiwa 2 June", + "reiwa", 2 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 28, monthCode: "M07", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.add(new Temporal.Duration(3)).toPlainDateTime(), + 2019, 7, "M07", 1, 12, 34, 0, 0, 0, 0, "Multiple years across era boundary: Adding 3 years to Heisei 28 July lands in Reiwa 1 July", + "reiwa", 1 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.add(duration1n).toPlainDateTime(), + 2019, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 June lands in Reiwa 1 June", + "reiwa", 1 +); + +const date7 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date7.add(duration1n).toPlainDateTime(), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 March lands in Heisei 31 March", + "heisei", 31 +); + +const date8 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M07", day: 10, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date8.add(duration1n).toPlainDateTime(), + 2018, 7, "M07", 10, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 1 July lands in Heisei 30 July", + "heisei", 30 +); + +const date9 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 4, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date9.add(new Temporal.Duration(-5)).toPlainDateTime(), + 2017, 2, "M02", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from Reiwa 4 February lands in Heisei 29 February", + "heisei", 29 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-japanese.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-japanese.js new file mode 100644 index 00000000000..96431233d39 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-japanese.js @@ -0,0 +1,81 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +// Reiwa era started on May 1, 2019 (Reiwa 1 = 2019) +// Heisei era: 1989-2019 (Heisei 31 ended April 30, 2019) + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "japanese"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(duration1).toPlainDateTime(), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 March (before May 1) lands in Heisei 31 March", + "heisei", 31 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 31, monthCode: "M04", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1).toPlainDateTime(), + 2020, 4, "M04", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 31 April (before May 1) lands in Reiwa 2 April", + "reiwa", 2 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 30, monthCode: "M06", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1).toPlainDateTime(), + 2019, 6, "M06", 12, 12, 34, 0, 0, 0, 0, "Adding 1 year to Heisei 30 June (after May 1) lands in Reiwa 1 June", + "reiwa", 1 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M06", day: 10, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(duration1).toPlainDateTime(), + 2020, 6, "M06", 10, 12, 34, 0, 0, 0, 0, "Adding 1 year to Reiwa 1 June lands in Reiwa 2 June", + "reiwa", 2 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "heisei", eraYear: 28, monthCode: "M07", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.subtract(new Temporal.Duration(-3)).toPlainDateTime(), + 2019, 7, "M07", 1, 12, 34, 0, 0, 0, 0, "Multiple years across era boundary: Adding 3 years to Heisei 28 July lands in Reiwa 1 July", + "reiwa", 1 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.subtract(duration1n).toPlainDateTime(), + 2019, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 June lands in Reiwa 1 June", + "reiwa", 1 +); + +const date7 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 2, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date7.subtract(duration1n).toPlainDateTime(), + 2019, 3, "M03", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 2 March lands in Heisei 31 March", + "heisei", 31 +); + +const date8 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 1, monthCode: "M07", day: 10, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date8.subtract(duration1n).toPlainDateTime(), + 2018, 7, "M07", 10, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from Reiwa 1 July lands in Heisei 30 July", + "heisei", 30 +); + +const date9 = Temporal.ZonedDateTime.from({ era: "reiwa", eraYear: 4, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date9.subtract(new Temporal.Duration(5)).toPlainDateTime(), + 2017, 2, "M02", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from Reiwa 4 February lands in Heisei 29 February", + "heisei", 29 +); From 6309fb50202654fb226402921651720c279b9722 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Fri, 7 Nov 2025 20:44:13 -0800 Subject: [PATCH 7/7] Intl Era Monthcode: Era boundary tests for roc calendar Co-Authored-By: Philip Chimento --- .../prototype/add/era-boundary-roc.js | 63 +++++++++++++++++++ .../prototype/subtract/era-boundary-roc.js | 63 +++++++++++++++++++ .../prototype/add/era-boundary-roc.js | 63 +++++++++++++++++++ .../prototype/subtract/era-boundary-roc.js | 63 +++++++++++++++++++ .../prototype/add/era-boundary-roc.js | 63 +++++++++++++++++++ .../prototype/subtract/era-boundary-roc.js | 63 +++++++++++++++++++ 6 files changed, 378 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/era-boundary-roc.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-roc.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-roc.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-roc.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-roc.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-roc.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-roc.js b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-roc.js new file mode 100644 index 00000000000..646b64396bc --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-roc.js @@ -0,0 +1,63 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "roc"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)", + "broc", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)", + "roc", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 ROC lands in 2 ROC", + "roc", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.add(new Temporal.Duration(10)), + 6, 3, "M03", 1, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)", + "roc", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.add(duration1n), + 4, 6, "M06", 15, "Subtracting 1 year from ROC 5 lands in ROC 4", + "roc", 4 +); + +TemporalHelpers.assertPlainDate( + date3.add(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from ROC 1 lands in BROC 1", + "broc", 1 +); + +const date6 = Temporal.PlainDate.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date6.add(new Temporal.Duration(-15)), + -5, 3, "M03", 1, "Subtracting 15 years from ROC 10 lands in BROC 6", + "broc", 6 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-roc.js b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-roc.js new file mode 100644 index 00000000000..3856ec5d03c --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-roc.js @@ -0,0 +1,63 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "roc"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)", + "broc", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)", + "roc", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 ROC lands in 2 ROC", + "roc", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date4.subtract(new Temporal.Duration(-10)), + 6, 3, "M03", 1, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)", + "roc", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.subtract(duration1n), + 4, 6, "M06", 15, "Subtracting 1 year from ROC 5 lands in ROC 4", + "roc", 4 +); + +TemporalHelpers.assertPlainDate( + date3.subtract(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from ROC 1 lands in BROC 1", + "broc", 1 +); + +const date6 = Temporal.PlainDate.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, calendar }, options); +TemporalHelpers.assertPlainDate( + date6.subtract(new Temporal.Duration(15)), + -5, 3, "M03", 1, "Subtracting 15 years from ROC 10 lands in BROC 6", + "broc", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-roc.js b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-roc.js new file mode 100644 index 00000000000..b83f6e343e8 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-roc.js @@ -0,0 +1,63 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "roc"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(duration1), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)", + "broc", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration1), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)", + "roc", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration1), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC", + "roc", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(new Temporal.Duration(10)), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)", + "roc", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.add(duration1n), + 4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4", + "roc", 4 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1", + "broc", 1 +); + +const date6 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.add(new Temporal.Duration(-15)), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6", + "broc", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-roc.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-roc.js new file mode 100644 index 00000000000..c8858bc4afe --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-roc.js @@ -0,0 +1,63 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "roc"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(duration1), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)", + "broc", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)", + "roc", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC", + "roc", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(new Temporal.Duration(-10)), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)", + "roc", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.subtract(duration1n), + 4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4", + "roc", 4 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1", + "broc", 1 +); + +const date6 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.subtract(new Temporal.Duration(15)), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6", + "broc", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-roc.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-roc.js new file mode 100644 index 00000000000..fc402d11a56 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-roc.js @@ -0,0 +1,63 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "roc"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.add(duration1).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)", + "broc", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.add(duration1).toPlainDateTime(), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)", + "roc", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.add(duration1).toPlainDateTime(), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC", + "roc", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.add(new Temporal.Duration(10)).toPlainDateTime(), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)", + "roc", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.add(duration1n).toPlainDateTime(), + 4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4", + "roc", 4 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1", + "broc", 1 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.add(new Temporal.Duration(-15)).toPlainDateTime(), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6", + "broc", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-roc.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-roc.js new file mode 100644 index 00000000000..5f8feea5932 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-roc.js @@ -0,0 +1,63 @@ +// 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: > + Adding years works correctly across era boundaries in calendars with eras +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "roc"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date1.subtract(duration1).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)", + "broc", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1).toPlainDateTime(), + 1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)", + "roc", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1).toPlainDateTime(), + 2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC", + "roc", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date4.subtract(new Temporal.Duration(-10)).toPlainDateTime(), + 6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)", + "roc", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date5.subtract(duration1n).toPlainDateTime(), + 4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4", + "roc", 4 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1", + "broc", 1 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options); +TemporalHelpers.assertPlainDateTime( + date6.subtract(new Temporal.Duration(15)).toPlainDateTime(), + -5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6", + "broc", 6 +);