Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 301738;
8 var summary = 'Date parse compatibilty with MSIE';
9 var actual = '';
10 var expect = '';
12 printBugNumber(BUGNUMBER);
13 printStatus (summary);
15 /*
16 Case 2. The input string is of the form "f/m/l" where f, m and l are
17 integers, e.g. 7/16/45.
18 Adjust the mon, mday and year values to achieve 100% MSIE
19 compatibility.
20 a. If 0 <= f < 70, f/m/l is interpreted as month/day/year.
21 i. If year < 100, it is the number of years after 1900
22 ii. If year >= 100, it is the number of years after 0.
23 b. If 70 <= f < 100
24 i. If m < 70, f/m/l is interpreted as
25 year/month/day where year is the number of years after
26 1900.
27 ii. If m >= 70, the date is invalid.
28 c. If f >= 100
29 i. If m < 70, f/m/l is interpreted as
30 year/month/day where year is the number of years after 0.
31 ii. If m >= 70, the date is invalid.
32 */
34 var f;
35 var m;
36 var l;
38 function newDate(f, m, l)
39 {
40 return new Date(f + '/' + m + '/' + l);
41 }
43 function newDesc(f, m, l)
44 {
45 return f + '/' + m + '/' + l;
46 }
48 // 2.a.i
49 f = 0;
50 m = 0;
51 l = 0;
53 expect = (new Date(l, f-1, m)).toDateString();
54 actual = newDate(f, m, l).toDateString();
55 reportCompare(expect, actual, newDesc(f, m, l));
57 f = 0;
58 m = 0;
59 l = 100;
61 expect = (new Date(l, f-1, m)).toDateString();
62 actual = newDate(f, m, l).toDateString();
63 reportCompare(expect, actual, newDesc(f, m, l));
65 // 2.a.ii
66 f = 0;
67 m = 24;
68 l = 100;
70 expect = (new Date(l, f-1, m)).toDateString();
71 actual = newDate(f, m, l).toDateString();
72 reportCompare(expect, actual, newDesc(f, m, l));
74 f = 0;
75 m = 24;
76 l = 2100;
78 expect = (new Date(l, f-1, m)).toDateString();
79 actual = newDate(f, m, l).toDateString();
80 reportCompare(expect, actual, newDesc(f, m, l));
83 // 2.b.i
84 f = 70;
85 m = 24;
86 l = 100;
88 expect = (new Date(f, m-1, l)).toDateString();
89 actual = newDate(f, m, l).toDateString();
90 reportCompare(expect, actual, newDesc(f, m, l));
92 f = 99;
93 m = 12;
94 l = 1;
96 expect = (new Date(f, m-1, l)).toDateString();
97 actual = newDate(f, m, l).toDateString();
98 reportCompare(expect, actual, newDesc(f, m, l));
100 // 2.b.ii.
102 f = 99;
103 m = 70;
104 l = 1;
106 expect = true;
107 actual = isNaN(newDate(f, m, l));
108 reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');
110 // 2.c.i
112 f = 100;
113 m = 12;
114 l = 1;
116 expect = (new Date(f, m-1, l)).toDateString();
117 actual = newDate(f, m, l).toDateString();
118 reportCompare(expect, actual, newDesc(f, m, l));
120 // 2.c.ii
122 f = 100;
123 m = 70;
124 l = 1;
126 expect = true;
127 actual = isNaN(newDate(f, m, l));
128 reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');