tor-browser

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

argument-string-date-with-utc-offset.js (1245B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2022 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.instant.from
      7 description: UTC offset not valid with format that does not include a time
      8 features: [Temporal]
      9 ---*/
     10 
     11 const validStrings = [
     12  "1970-01-01T00Z",
     13  "1970-01-01T00Z[UTC]",
     14  "1970-01-01T00Z[!UTC]",
     15  "1970-01-01T00Z[Europe/Vienna]",
     16  "1970-01-01T00+00:00",
     17  "1970-01-01T00+00:00[UTC]",
     18  "1970-01-01T00+00:00[!UTC]",
     19  "1969-12-31T16-08:00[America/Vancouver]",
     20 ];
     21 
     22 for (const arg of validStrings) {
     23  const result = Temporal.Instant.from(arg);
     24 
     25  assert.sameValue(
     26    result.epochNanoseconds,
     27    0n,
     28    `"${arg}" is a valid UTC offset with time for Instant`
     29  );
     30 }
     31 
     32 const invalidStrings = [
     33  "2022-09-15Z",
     34  "2022-09-15Z[UTC]",
     35  "2022-09-15Z[Europe/Vienna]",
     36  "2022-09-15+00:00",
     37  "2022-09-15+00:00[UTC]",
     38  "2022-09-15-02:30",
     39  "2022-09-15-02:30[America/St_Johns]",
     40 ];
     41 
     42 for (const arg of invalidStrings) {
     43  assert.throws(
     44    RangeError,
     45    () => Temporal.Instant.from(arg),
     46    `"${arg}" UTC offset without time is not valid for Instant`
     47  );
     48 }
     49 
     50 reportCompare(0, 0);