tor-browser

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

twenty-five-hour-day.js (1089B)


      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.duration.compare
      7 description: Unbalancing handles DST days with more than 24 hours
      8 features: [Temporal]
      9 ---*/
     10 
     11 // 2000-10-29 is a 25-hour day according to this time zone...
     12 
     13 const relativeTo = new Temporal.ZonedDateTime(941184000_000_000_000n, "America/Vancouver");
     14 
     15 // confirm that we have rewound one year and one day:
     16 assert.sameValue('1999-10-29T01:00:00-07:00[America/Vancouver]', relativeTo.toString());
     17 
     18 const d1 = new Temporal.Duration(1, 0, 0, 1);
     19 const d2 = new Temporal.Duration(1, 0, 0, 0, 25);
     20 
     21 // ...so the durations should be equal relative to relativeTo:
     22 
     23 assert.sameValue(0,
     24  Temporal.Duration.compare(d1, d2, { relativeTo }),
     25  "2000-10-29 is a 25-hour day"
     26 );
     27 
     28 assert.sameValue(1,
     29  Temporal.Duration.compare(d1, { years: 1, hours: 24 }, { relativeTo }),
     30  "2020-10-29 has more than 24 hours"
     31 );
     32 
     33 reportCompare(0, 0);