tor-browser

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

relativeto-sub-minute-offset.js (1351B)


      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.duration.compare
      7 description: relativeTo string accepts trailing zeroes in sub-minute UTC offset
      8 features: [Temporal]
      9 ---*/
     10 
     11 const duration1 = new Temporal.Duration(0, 0, 0, 31);
     12 const duration2 = new Temporal.Duration(0, 1);
     13 
     14 let result;
     15 let relativeTo;
     16 
     17 const action = (relativeTo) => Temporal.Duration.compare(duration1, duration2, { relativeTo });
     18 
     19 relativeTo = "1970-01-01T00:00-00:45:00[-00:45]";
     20 result = action(relativeTo);
     21 assert.sameValue(result, 0, "ISO string offset accepted with zero seconds (string)");
     22 
     23 relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" };
     24 result = action(relativeTo);
     25 assert.sameValue(result, 0, "ISO string offset accepted with zero seconds (property bag)");
     26 
     27 relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]";
     28 assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone");
     29 
     30 relativeTo = "1970-01-01T00:00-00:44:59[-00:44:59]";
     31 assert.throws(RangeError, () => action(relativeTo), "sub-minute offset not accepted as time zone identifier");
     32 
     33 reportCompare(0, 0);