constructor-options-calendar-islamic-fallback.js (2112B)
1 // Copyright (C) 2025 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: > 7 Tests that fallbacks for deprecated calendars are selected from one of the 8 values returned from `AvailableCalendars`. 9 info: | 10 CreateDateTimeFormat ( _newTarget_, _locales_, _options_, _required_, _defaults_ ) 11 12 ... 13 9. If _resolvedCalendar_ is *"islamic"* or *"islamic-rgsa"*, then 14 a. Let _fallbackCalendar_ be an implementation- and locale-defined calendar type that is one of the values returned from AvailableCalendars. 15 b. Set _resolvedCalendar_ to CanonicalizeUValue(*"ca"*, _fallbackCalendar_). 16 c. If the ECMAScript implementation has a mechanism for reporting diagnostic warning messages, a warning should be issued. 17 10. Set _dateTimeFormat_.[[Calendar]] to _resolvedCalendar_. 18 locale: [en] 19 features: [Intl.Era-monthcode] 20 ---*/ 21 22 const availableCalendars = [ 23 "buddhist", 24 "chinese", 25 "coptic", 26 "dangi", 27 "ethioaa", 28 "ethiopic", 29 "gregory", 30 "hebrew", 31 "indian", 32 "islamic-civil", 33 "islamic-tbla", 34 "islamic-umalqura", 35 "iso8601", 36 "japanese", 37 "persian", 38 "roc", 39 ]; 40 41 const islamic = new Intl.DateTimeFormat("en", { calendar: "islamic" }); 42 assert.sameValue(availableCalendars.includes(islamic.resolvedOptions().calendar), true, "no valid fallback for 'islamic' calendar option"); 43 44 const islamicRgsa = new Intl.DateTimeFormat("en", { calendar: "islamic-rgsa" }); 45 assert.sameValue(availableCalendars.includes(islamicRgsa.resolvedOptions().calendar), true, "no valid fallback for 'islamic-rgsa' calendar option"); 46 47 const islamicUExtension = new Intl.DateTimeFormat("en-u-ca-islamic"); 48 assert.sameValue(availableCalendars.includes(islamicUExtension.resolvedOptions().calendar), true, "no valid fallback for 'islamic' calendar u extension"); 49 50 const islamicRgsaUExtension = new Intl.DateTimeFormat("en-u-ca-islamic-rgsa"); 51 assert.sameValue(availableCalendars.includes(islamicRgsaUExtension.resolvedOptions().calendar), true, "no valid fallback for 'islamic-rgsa' calendar u extension"); 52 53 reportCompare(0, 0);