Debian Codegraph @

js/src/tests/non262/Date/parse-num-preceding-alpha.js

raw
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 assertEq(new Date("15AUG2015").getTime(),
7 new Date(2015, Month.August, 15).getTime());
8
9 assertEq(new Date("Aug 15, 2015 10:00am").getTime(),
10 new Date(2015, Month.August, 15, 10).getTime());
11 assertEq(new Date("Aug 15, 2015 10:00pm").getTime(),
12 new Date(2015, Month.August, 15, 22).getTime());
13
14 const rejects = [
15 "2023+/08/12",
16 "2023/08+/12",
17 "12Aug2023Sat",
18 "2023/08/12 12:34:56+0900+",
19 "2023/08/12 12:34:56+0900-",
20 "2023/08/12 12:34:56+09:00+",
21 "2023/08/12 12:34:56+09:00-",
22 "2023/08/12 12:34:56 +09:00+",
23 "2023/08/12 12:34:56GMT+0900,",
24 "2023/08/12 12:34:56GMT+0900.",
25 "2023/08/12 12:34:56GMT+0900/",
26 "2023/08/12 12:34:56GMT+0900+",
27 "2023/08/12 12:34:56GMT+0900-",
28 "2023/08/12 12:34:56GMT+09:30,",
29 "2023/08/12 12:34:56GMT+09:30.",
30 "2023/08/12 12:34:56GMT+09:30/",
31 "2023/08/12 12:34:56GMT+09:30+",
32 "2023/08/12 12:34:56GMT+09:30-",
33 "2023/08/12 12:34:56 +09:30+",
34 "2023/08/12 12:34:56 GMT+09:30+",
35 "2023/08/12 12:34:56.",
36 "2023/08/12 12:34:56.-0900",
37 "2023/08/12 12:34:56PST",
38 ];
39 for (const reject of rejects) {
40 assertEq(isNaN(new Date(reject)), true, `"${reject}" should be rejected.`);
41 }
42
43 if (typeof reportCompare === "function")
44 reportCompare(true, true);