canonicalize-era-codes-non-gregorian.js (971B)
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.zonedatetime.from 7 description: Calendar era code is canonicalized (non-Gregorian calendars) 8 features: [Temporal, Intl.Era-monthcode] 9 ---*/ 10 11 12 const calendarEraAliases = [ 13 { calendar: "japanese", canonicalizedEra: "ce", alias: "ad" }, 14 { calendar: "japanese", canonicalizedEra: "bce", alias: "bc" } 15 ]; 16 17 18 for (const calendarEraAlias of calendarEraAliases) { 19 const calendar = Temporal.ZonedDateTime.from({ 20 calendar: calendarEraAlias.calendar, 21 era: calendarEraAlias.alias, 22 eraYear: 1, 23 month: 1, 24 day: 1, 25 timeZone: "UTC" 26 }); 27 assert.sameValue(calendar.era, calendarEraAlias.canonicalizedEra, calendar.era + " should canonicalize to " + calendarEraAlias.canonicalizedEra) 28 } 29 30 reportCompare(0, 0);