Debian Codegraph @

js/src/tests/test262/intl402/Intl/supportedValuesOf/timeZones-accepted-by-DateTimeFormat.js

raw
1 // Copyright (C) 2021 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-intl.supportedvaluesof
6 description: >
7 The returned "timeZone" values can be used with DateTimeFormat.
8 info: |
9 Intl.supportedValuesOf ( key )
10
11 1. Let key be ? ToString(key).
12 ...
13 6. Else if key is "timeZone", then
14 a. Let list be ! AvailableTimeZones( ).
15 ...
16 9. Return ! CreateArrayFromList( list ).
17
18 AvailableTimeZones ()
19 The AvailableTimeZones abstract operation returns a sorted List of supported
20 Zone and Link names in the IANA Time Zone Database. The following steps are
21 taken:
22
23 1. Let names be a List of all supported Zone and Link names in the IANA Time
24 Zone Database.
25 2. Let result be a new empty List.
26 3. For each element name of names, do
27 a. Assert: ! IsValidTimeZoneName( name ) is true.
28 b. Let canonical be ! CanonicalizeTimeZoneName( name ).
29 c. If result does not contain an element equal to canonical, then
30 i. Append canonical to the end of result.
31 4. Sort result in order as if an Array of the same values had been sorted using
32 %Array.prototype.sort% using undefined as comparefn.
33 5. Return result.
34 locale: [en]
35 features: [Intl-enumeration]
36 ---*/
37
38 const timeZones = Intl.supportedValuesOf("timeZone");
39
40 for (let timeZone of timeZones) {
41 let obj = new Intl.DateTimeFormat("en", {timeZone});
42 assert.sameValue(obj.resolvedOptions().timeZone, timeZone,
43 `${timeZone} is supported by DateTimeFormat`);
44 }
45
46 reportCompare(0, 0);