tor-browser

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

parse-period.js (1318B)


      1 // |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable
      2 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 const tests = [
      8  "Aug. 15, 2015",
      9  "Aug.. 15, 2015",
     10  "Aug.15.2015",
     11  "15.Aug.2015",
     12  "15.Aug.0015",
     13  "Aug 15 2015 12:00 am.",
     14  "Sat. Aug 15 2015",
     15  "2015.08.15",
     16  "2015.08.15.00:00:00",
     17 
     18  // These look weird but are accepted for Chrome parity
     19  // (dots are valid delimiters and are essentially ignored)
     20  "2015./08/15 00:00:00",
     21  "2015/08./15 00:00:00",
     22 ];
     23 const rejected = [
     24  "2015/08/15 00:00:00.",
     25  "2015/08/15 00:00:00.GMT",
     26 ];
     27 
     28 for (const test of tests) {
     29  assertEq(new Date(test).getTime(),
     30           new Date(2015, Month.August, 15).getTime(),
     31           `"${test}" should be accepted.`);
     32 }
     33 
     34 for (const reject of rejected) {
     35  assertEq(
     36    true, isNaN(new Date(reject)),
     37    `"${reject}" should be rejected.`
     38  );
     39 }
     40 
     41 inTimeZone("Etc/GMT-1", () => {
     42  let dt = new Date("Aug 15 2015 GMT.");
     43  assertEq(dt.getTime(), new Date(2015, Month.August, 15, 1).getTime());
     44 });
     45 
     46 if (typeof reportCompare === "function")
     47  reportCompare(true, true);