era-boundary-roc.js (1565B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2025 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.plaindatetime.from 7 description: Non-positive era years are remapped in roc calendar 8 includes: [temporalHelpers.js] 9 features: [Temporal, Intl.Era-monthcode] 10 ---*/ 11 12 const calendar = "roc"; 13 const options = { overflow: "reject" }; 14 15 const roc0 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 0, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); 16 TemporalHelpers.assertPlainDateTime( 17 roc0, 18 0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "ROC 0 resolves to BROC 1", 19 "broc", 1); 20 21 const roc1n = Temporal.PlainDateTime.from({ era: "roc", eraYear: -1, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); 22 TemporalHelpers.assertPlainDateTime( 23 roc1n, 24 -1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "ROC -1 resolves to BROC 2", 25 "broc", 2); 26 27 const broc0 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 0, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); 28 TemporalHelpers.assertPlainDateTime( 29 broc0, 30 1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "BROC 0 resolves to ROC 1", 31 "roc", 1); 32 33 const broc1n = Temporal.PlainDateTime.from({ era: "broc", eraYear: -1, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options); 34 TemporalHelpers.assertPlainDateTime( 35 broc1n, 36 2, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "BROC -1 resolves to ROC 2", 37 "roc", 2); 38 39 reportCompare(0, 0);