|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 = 301738; |
|
8 var summary = 'Date parse compatibilty with MSIE'; |
|
9 var actual = ''; |
|
10 var expect = ''; |
|
11 |
|
12 printBugNumber(BUGNUMBER); |
|
13 printStatus (summary); |
|
14 |
|
15 /* |
|
16 Case 1. The input string contains an English month name. |
|
17 The form of the string can be month f l, or f month l, or |
|
18 f l month which each evaluate to the same date. |
|
19 If f and l are both greater than or equal to 70, or |
|
20 both less than 70, the date is invalid. |
|
21 The year is taken to be the greater of the values f, l. |
|
22 If the year is greater than or equal to 70 and less than 100, |
|
23 it is considered to be the number of years after 1900. |
|
24 */ |
|
25 |
|
26 var month = 'January'; |
|
27 var f; |
|
28 var l; |
|
29 |
|
30 f = l = 0; |
|
31 expect = true; |
|
32 |
|
33 actual = isNaN(new Date(month + ' ' + f + ' ' + l)); |
|
34 reportCompare(expect, actual, 'January 0 0 is invalid'); |
|
35 |
|
36 actual = isNaN(new Date(f + ' ' + l + ' ' + month)); |
|
37 reportCompare(expect, actual, '0 0 January is invalid'); |
|
38 |
|
39 actual = isNaN(new Date(f + ' ' + month + ' ' + l)); |
|
40 reportCompare(expect, actual, '0 January 0 is invalid'); |
|
41 |
|
42 f = l = 70; |
|
43 |
|
44 actual = isNaN(new Date(month + ' ' + f + ' ' + l)); |
|
45 reportCompare(expect, actual, 'January 70 70 is invalid'); |
|
46 |
|
47 actual = isNaN(new Date(f + ' ' + l + ' ' + month)); |
|
48 reportCompare(expect, actual, '70 70 January is invalid'); |
|
49 |
|
50 actual = isNaN(new Date(f + ' ' + month + ' ' + l)); |
|
51 reportCompare(expect, actual, '70 January 70 is invalid'); |
|
52 |
|
53 f = 100; |
|
54 l = 15; |
|
55 |
|
56 // year, month, day |
|
57 expect = new Date(f, 0, l).toString(); |
|
58 |
|
59 actual = new Date(month + ' ' + f + ' ' + l).toString(); |
|
60 reportCompare(expect, actual, 'month f l'); |
|
61 |
|
62 actual = new Date(f + ' ' + l + ' ' + month).toString(); |
|
63 reportCompare(expect, actual, 'f l month'); |
|
64 |
|
65 actual = new Date(f + ' ' + month + ' ' + l).toString(); |
|
66 reportCompare(expect, actual, 'f month l'); |
|
67 |
|
68 f = 80; |
|
69 l = 15; |
|
70 |
|
71 // year, month, day |
|
72 expect = (new Date(f, 0, l)).toString(); |
|
73 |
|
74 actual = (new Date(month + ' ' + f + ' ' + l)).toString(); |
|
75 reportCompare(expect, actual, 'month f l'); |
|
76 |
|
77 actual = (new Date(f + ' ' + l + ' ' + month)).toString(); |
|
78 reportCompare(expect, actual, 'f l month'); |
|
79 |
|
80 actual = (new Date(f + ' ' + month + ' ' + l)).toString(); |
|
81 reportCompare(expect, actual, 'f month l'); |
|
82 |
|
83 f = 2040; |
|
84 l = 15; |
|
85 |
|
86 // year, month, day |
|
87 expect = (new Date(f, 0, l)).toString(); |
|
88 |
|
89 actual = (new Date(month + ' ' + f + ' ' + l)).toString(); |
|
90 reportCompare(expect, actual, 'month f l'); |
|
91 |
|
92 actual = (new Date(f + ' ' + l + ' ' + month)).toString(); |
|
93 reportCompare(expect, actual, 'f l month'); |
|
94 |
|
95 actual = (new Date(f + ' ' + month + ' ' + l)).toString(); |
|
96 reportCompare(expect, actual, 'f month l'); |
|
97 |