canonicalize-era-codes.js (855B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2024 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.zoneddatetime.from 7 description: Calendar era code is canonicalized 8 features: [Temporal, Intl.Era-monthcode] 9 ---*/ 10 11 const date1 = Temporal.ZonedDateTime.from({ 12 calendar: "gregory", 13 era: "ad", 14 eraYear: 2024, 15 year: 2024, 16 month: 1, 17 day: 1, 18 timeZone: "UTC", 19 }); 20 assert.sameValue(date1.era, "ce", "'ad' is accepted as alias for 'ce'"); 21 22 const date2 = Temporal.ZonedDateTime.from({ 23 calendar: "gregory", 24 era: "bc", 25 eraYear: 44, 26 year: -43, 27 month: 3, 28 day: 15, 29 timeZone: "Europe/Rome", 30 }); 31 assert.sameValue(date2.era, "bce", "'bc' is accepted as alias for 'bce'"); 32 33 reportCompare(0, 0);