tor-browser

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

parse-year-after-timezone.js (1208B)


      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 const accepted = {
      7  "1997-11-05T00:00:00-0800": [
      8    "Wed Nov 05 00:00:00 GMT-0800 1997",
      9    "Nov 05 00:00:00 GMT-0800 1997",
     10    "Nov-05 00:00:00 GMT-0800 1997",
     11    "05-Nov 00:00:00 GMT-0800 1997",
     12    "05-Nov GMT-0800 1997",
     13  ],
     14 
     15  "-001997-11-05T00:00:00-0800": [
     16    "Wed Nov 05 00:00:00 GMT-0800 -1997",
     17    "Nov 05 00:00:00 GMT-0800 -1997",
     18    "Nov-05 00:00:00 GMT-0800 -1997",
     19    "05-Nov 00:00:00 GMT-0800 -1997",
     20    "05-Nov GMT-0800 -1997",
     21  ],
     22 };
     23 
     24 for (const [expected, patterns] of Object.entries(accepted)) {
     25  for (const test of patterns) {
     26    const testDate = new Date(test);
     27    const expectedDate = new Date(expected);
     28 
     29    assertEq(
     30      false, isNaN(testDate),
     31      `${test} should be accepted.`
     32    );
     33 
     34    assertEq(
     35      testDate.getTime(), expectedDate.getTime(),
     36      `"${test}" should be ${expectedDate} (got ${testDate}).`
     37    );
     38  }
     39 }
     40 
     41 if (typeof reportCompare === "function")
     42    reportCompare(true, true);