tor-browser

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

15.9.4.2.js (1506B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 //-----------------------------------------------------------------------------
      7 var BUGNUMBER = 682754;
      8 
      9 
     10 //-----------------------------------------------------------------------------
     11 test();
     12 //-----------------------------------------------------------------------------
     13 
     14 function iso(d)
     15 {
     16  return new Date(d).toISOString();
     17 }
     18 
     19 function check(s, millis){
     20  description = "Date.parse('"+s+"') == '"+iso(millis)+"'";
     21  expected = millis;
     22  actual = Date.parse(s);
     23  reportCompare(expected, actual, description);
     24 }
     25 
     26 function checkInvalid(s)
     27 {
     28  description = "Date.parse('"+s+"') produces invalid date";
     29  expected = NaN;
     30  actual = Date.parse(s);
     31  reportCompare(expected, actual, description);
     32 }
     33 
     34 function dd(year, month, day, hour, minute, second, millis){
     35  return Date.UTC(year, month-1, day, hour, minute, second, millis);
     36 }
     37 
     38 function TZAtDate(d){
     39  return d.getTimezoneOffset() * 60000;
     40 }
     41 
     42 function TZInMonth(month){
     43  return TZAtDate(new Date(dd(2009,month,1,0,0,0,0)));
     44 }
     45 
     46 function test()
     47 {
     48  printBugNumber(BUGNUMBER);
     49 
     50  JanTZ = TZInMonth(1);
     51  JulTZ = TZInMonth(7);
     52  CurrTZ = TZAtDate(new Date());
     53 
     54  // Allow non-standard "-0700" as timezone, not just "-07:00"
     55  check("2009-07-23T00:53:21.001-0700", dd(2009,7,23,7,53,21,1));
     56 }