tor-browser

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

time-zone-etc_localetime.js (1110B)


      1 // |reftest| skip-if(winWidget||!xulRuntime.shell||!this.hasOwnProperty('Intl'))
      2 
      3 assertEq(/^(PST|PDT)$/.test(getTimeZone()), true,
      4         "The default time zone is set to PST8PDT for all jstests (when run in the shell)");
      5 
      6 function timeZoneName() {
      7    var dtf = new Intl.DateTimeFormat("en-US", {timeZoneName: "long"});
      8    return dtf.formatToParts().filter(x => x.type === "timeZoneName")[0].value;
      9 }
     10 
     11 // Calling setTimeZone() with an undefined argument clears the TZ environment
     12 // variable and by that reveal the actual system time zone.
     13 setTimeZone(undefined);
     14 var systemTimeZone = getTimeZone();
     15 var systemTimeZoneName = timeZoneName();
     16 
     17 // Set to an unlikely system time zone, so that the next call to setTimeZone()
     18 // will lead to a time zone change.
     19 setTimeZone("Antarctica/Troll");
     20 
     21 // Now call with the file path ":/etc/localtime" which is special-cased in
     22 // DateTimeInfo to read the system time zone.
     23 setTimeZone(":/etc/localtime");
     24 
     25 assertEq(getTimeZone(), systemTimeZone);
     26 assertEq(timeZoneName(), systemTimeZoneName);
     27 
     28 if (typeof reportCompare === "function")
     29    reportCompare(true, true);