tor-browser

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

timezone-ids-basic.js (1009B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2021 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.zoneddatetime
      7 description: Basic tests for time zone IDs
      8 features: [Temporal, canonical-tz]
      9 ---*/
     10 
     11 const valid = [
     12  ["Europe/Vienna"],
     13  ["America/New_York"],
     14  ["Africa/CAIRO", "Africa/Cairo"],
     15  ["africa/cairo", "Africa/Cairo"],
     16  ["Asia/Ulaanbaatar"],
     17  ["Asia/Ulan_Bator"],
     18  ["UTC"],
     19  ["GMT"]
     20 ];
     21 for (const [zone, id = zone] of valid) {
     22  const result = new Temporal.ZonedDateTime(0n, zone);
     23  assert.sameValue(typeof result, "object", `object should be created for ${zone}`);
     24  assert.sameValue(result.timeZoneId, id, `id for ${zone} should be ${id}`);
     25 }
     26 
     27 const invalid = ["+00:01.1", "-01.1"];
     28 for (const zone of invalid) {
     29  assert.throws(RangeError, () => new Temporal.ZonedDateTime(0n, zone), `should throw for ${zone}`);
     30 }
     31 
     32 reportCompare(0, 0);