From 48c56238b62b740c891a89d0d8dcffd2bb023abc Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Fri, 7 Nov 2025 20:44:13 -0800 Subject: [PATCH] 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 0000000000..646b64396b --- /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 0000000000..3856ec5d03 --- /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 0000000000..b83f6e343e --- /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 0000000000..c8858bc4af --- /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 0000000000..fc402d11a5 --- /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 0000000000..5f8feea593 --- /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 +);