tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

canonicalize-utc-timezone.js (1213B)


      1 // Copyright 2024 Igalia, S.L. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-createdatetimeformat
      5 description: >
      6  Tests that the time zone names "Etc/UTC", "Etc/GMT", and "GMT" are not
      7  canonicalized to "UTC" in "resolvedOptions".
      8 info: |
      9  CreateDateTimeFormat ( dateTimeFormat, locales, options, required, default )
     10 
     11  30. If IsTimeZoneOffsetString(timeZone) is true, then
     12  ...
     13  31. Else,
     14    a. Let timeZoneIdentifierRecord be GetAvailableNamedTimeZoneIdentifier(timeZone).
     15    ...
     16    c. Set timeZone to timeZoneIdentifierRecord.[[Identifier]].
     17 
     18  GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )
     19 
     20  1. For each element record of AvailableNamedTimeZoneIdentifiers(), do
     21    a. If record.[[Identifier]] is an ASCII-case-insensitive match for
     22       timeZoneIdentifier, return record.
     23 
     24 features: [canonical-tz]
     25 ---*/
     26 
     27 const utcIdentifiers = ["Etc/GMT", "Etc/UTC", "GMT"];
     28 
     29 for (const timeZone of utcIdentifiers) {
     30  assert.sameValue(
     31    new Intl.DateTimeFormat([], {timeZone}).resolvedOptions().timeZone,
     32    timeZone,
     33    "Time zone name " + timeZone + " should be preserved and not canonicalized to 'UTC'");
     34 }
     35 
     36 reportCompare(0, 0);