From 7ab1a79c0ee3a0ba4c23eaa6311a5ac44c1461bf Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 18 Nov 2025 16:05:03 -0800 Subject: [PATCH] Temporal: Add tests for addition/subtraction across era boundaries for Hijri calendars --- .../add/era-boundary-islamic-civil.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-tbla.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-umalqura.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-civil.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-tbla.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-umalqura.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-civil.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-tbla.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-umalqura.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-civil.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-tbla.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-umalqura.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-civil.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-tbla.js | 68 +++++++++++++++++++ .../add/era-boundary-islamic-umalqura.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-civil.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-tbla.js | 68 +++++++++++++++++++ .../subtract/era-boundary-islamic-umalqura.js | 68 +++++++++++++++++++ 18 files changed, 1224 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-umalqura.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-civil.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-tbla.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-umalqura.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-civil.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-tbla.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-umalqura.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-civil.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-tbla.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-umalqura.js diff --git a/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-civil.js b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-civil.js new file mode 100644 index 0000000000..739319647f --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-civil.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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.add(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDate( + date3.add(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDate( + date2.add(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-tbla.js b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-tbla.js new file mode 100644 index 0000000000..b374eab10b --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-tbla.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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.add(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDate( + date3.add(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDate( + date2.add(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-umalqura.js b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-umalqura.js new file mode 100644 index 0000000000..b805be7dc5 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/add/era-boundary-islamic-umalqura.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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.add(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.add(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.add(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.add(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDate( + date3.add(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDate( + date2.add(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-civil.js b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-civil.js new file mode 100644 index 0000000000..e11ee34c62 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-civil.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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.subtract(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDate( + date3.subtract(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDate( + date2.subtract(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-tbla.js b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-tbla.js new file mode 100644 index 0000000000..20cb1d1845 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-tbla.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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.subtract(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDate( + date3.subtract(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDate( + date2.subtract(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-umalqura.js b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-umalqura.js new file mode 100644 index 0000000000..dcc33fd601 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/subtract/era-boundary-islamic-umalqura.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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date1.subtract(duration1), + 0, 6, "M06", 15, "Adding 1 year to 2 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date2.subtract(duration1), + 1, 6, "M06", 15, "Adding 1 year to 1 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date3.subtract(duration1), + 2, 6, "M06", 15, "Adding 1 year to 1 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDate.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M06", day: 15, calendar }, options); +TemporalHelpers.assertPlainDate( + date5.subtract(duration1n), + 1, 6, "M06", 15, "Subtracting 1 year from 2 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDate( + date3.subtract(duration1n), + 0, 6, "M06", 15, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDate( + date2.subtract(duration1n), + -1, 6, "M06", 15, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDate.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-civil.js b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-civil.js new file mode 100644 index 0000000000..3b3a85bebf --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-civil.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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-tbla.js b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-tbla.js new file mode 100644 index 0000000000..677c580952 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-tbla.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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-umalqura.js b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-umalqura.js new file mode 100644 index 0000000000..39a423e1b4 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/add/era-boundary-islamic-umalqura.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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-civil.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-civil.js new file mode 100644 index 0000000000..fe601beaa7 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-civil.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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-tbla.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-tbla.js new file mode 100644 index 0000000000..be6c7f562f --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-tbla.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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-umalqura.js b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-umalqura.js new file mode 100644 index 0000000000..8f3c0e61b6 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/subtract/era-boundary-islamic-umalqura.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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +const date1 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.PlainDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.PlainDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-civil.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-civil.js new file mode 100644 index 0000000000..2d5fad4c3d --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-civil.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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-tbla.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-tbla.js new file mode 100644 index 0000000000..6f31b2934a --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-tbla.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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-umalqura.js b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-umalqura.js new file mode 100644 index 0000000000..59aee5d9e6 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/add/era-boundary-islamic-umalqura.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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration1n = new Temporal.Duration(-1); +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.add(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.add(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-civil.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-civil.js new file mode 100644 index 0000000000..a14653c5d4 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-civil.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 islamic-civil calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-civil"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-tbla.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-tbla.js new file mode 100644 index 0000000000..d5a87b0a6a --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-tbla.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 islamic-tbla calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-tbla"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-umalqura.js b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-umalqura.js new file mode 100644 index 0000000000..ecb07f45bb --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/subtract/era-boundary-islamic-umalqura.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 islamic-umalqura calendar +includes: [temporalHelpers.js] +features: [Temporal, Intl.Era-monthcode] +---*/ + +const duration1 = new Temporal.Duration(-1); +const duration1n = new Temporal.Duration(1); +const calendar = "islamic-umalqura"; +const options = { overflow: "reject" }; + +const date1 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 BH (counts backwards)", + "bh", 1 +); + +const date2 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 1 AH (no year zero)", + "ah", 1 +); + +const date3 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 2 AH", + "ah", 2 +); + +const date4 = Temporal.ZonedDateTime.from({ era: "bh", 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 BH lands in 6 AH (no year zero)", + "ah", 6 +); + +const date5 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 1 AH", + "ah", 1 +); + +TemporalHelpers.assertPlainDateTime( + date3.subtract(duration1n).toPlainDateTime(), + 0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 AH lands in 1 BH", + "bh", 1 +); + +TemporalHelpers.assertPlainDateTime( + date2.subtract(duration1n).toPlainDateTime(), + -1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from 1 BH lands in 2 BH", + "bh", 2 +); + +const date6 = Temporal.ZonedDateTime.from({ era: "ah", 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 AH lands in 6 BH", + "bh", 6 +);