era-boundary-islamic-civil.js (1345B)
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.plaindate.from 7 description: Non-positive era years are remapped in islamic-civil calendar 8 includes: [temporalHelpers.js] 9 features: [Temporal, Intl.Era-monthcode] 10 ---*/ 11 12 const calendar = "islamic-civil"; 13 const options = { overflow: "reject" }; 14 15 const ah0 = Temporal.PlainDate.from({ era: "ah", eraYear: 0, monthCode: "M01", day: 1, calendar }, options); 16 TemporalHelpers.assertPlainDate( 17 ah0, 18 0, 1, "M01", 1, "AH 0 resolves to BH 1", 19 "bh", 1); 20 21 const ah1n = Temporal.PlainDate.from({ era: "ah", eraYear: -1, monthCode: "M01", day: 1, calendar }, options); 22 TemporalHelpers.assertPlainDate( 23 ah1n, 24 -1, 1, "M01", 1, "AH -1 resolves to BH 2", 25 "bh", 2); 26 27 const bh0 = Temporal.PlainDate.from({ era: "bh", eraYear: 0, monthCode: "M01", day: 1, calendar }, options); 28 TemporalHelpers.assertPlainDate( 29 bh0, 30 1, 1, "M01", 1, "BH 0 resolves to AH 1", 31 "ah", 1); 32 33 const bh1n = Temporal.PlainDate.from({ era: "bh", eraYear: -1, monthCode: "M01", day: 1, calendar }, options); 34 TemporalHelpers.assertPlainDate( 35 bh1n, 36 2, 1, "M01", 1, "BH -1 resolves to AH 2", 37 "ah", 2); 38 39 reportCompare(0, 0);