canonicalize-calendar.js (958B)
1 // Copyright (C) 2024 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-intl.datetimeformat 6 description: Calendar IDs are canonicalized 7 locale: [en, en-u-ca-islamic-civil] 8 ---*/ 9 10 const fmt1 = new Intl.DateTimeFormat("en", { calendar: "islamicc" }); 11 assert.sameValue(fmt1.resolvedOptions().calendar, "islamic-civil", "calendar ID is canonicalized (option)"); 12 13 const fmt2 = new Intl.DateTimeFormat("en-u-ca-islamicc"); 14 assert.sameValue(fmt1.resolvedOptions().calendar, "islamic-civil", "calendar ID is canonicalized (locale key)"); 15 16 const fmt3 = new Intl.DateTimeFormat("en", { calendar: "ISO8601" }); 17 assert.sameValue(fmt3.resolvedOptions().calendar, "iso8601", "calendar ID is lowercased"); 18 19 assert.throws( 20 RangeError, 21 () => new Intl.DateTimeFormat("en", { calendar: "\u0130SO8601" }), 22 "calendar ID is capital dotted I is not lowercased (first argument)" 23 ); 24 25 reportCompare(0, 0);