Debian Codegraph @

rhino/testsrc/tests/js1_5/Date/regress-301738-02.js

raw symbols SCIP
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 var gTestfile = 'regress-301738-02.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 301738;
9 var summary = 'Date parse compatibilty with MSIE';
10 var actual = '';
11 var expect = '';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 /*
17 Case 2. The input string is of the form "f/m/l" where f, m and l are
18 integers, e.g. 7/16/45.
19 Adjust the mon, mday and year values to achieve 100% MSIE
20 compatibility.
21 a. If 0 <= f < 70, f/m/l is interpreted as month/day/year.
22 i. If year < 100, it is the number of years after 1900
23 ii. If year >= 100, it is the number of years after 0.
24 b. If 70 <= f < 100
25 i. If m < 70, f/m/l is interpreted as
26 year/month/day where year is the number of years after
27 1900.
28 ii. If m >= 70, the date is invalid.
29 c. If f >= 100
30 i. If m < 70, f/m/l is interpreted as
31 year/month/day where year is the number of years after 0.
32 ii. If m >= 70, the date is invalid.
33 */
34
35 var f;
36 var m;
37 var l;
38
39 function newDate(f, m, l)
40 {
41 return new Date(f + '/' + m + '/' + l);
42 }
43
44 function newDesc(f, m, l)
45 {
46 return f + '/' + m + '/' + l;
47 }
48
49 // 2.a.i
50 f = 0;
51 m = 0;
52 l = 0;
53
54 expect = (new Date(l, f-1, m)).toDateString();
55 actual = newDate(f, m, l).toDateString();
56 reportCompare(expect, actual, newDesc(f, m, l));
57
58 f = 0;
59 m = 0;
60 l = 100;
61
62 expect = (new Date(l, f-1, m)).toDateString();
63 actual = newDate(f, m, l).toDateString();
64 reportCompare(expect, actual, newDesc(f, m, l));
65
66 // 2.a.ii
67 f = 0;
68 m = 24;
69 l = 100;
70
71 expect = (new Date(l, f-1, m)).toDateString();
72 actual = newDate(f, m, l).toDateString();
73 reportCompare(expect, actual, newDesc(f, m, l));
74
75 f = 0;
76 m = 24;
77 l = 2100;
78
79 expect = (new Date(l, f-1, m)).toDateString();
80 actual = newDate(f, m, l).toDateString();
81 reportCompare(expect, actual, newDesc(f, m, l));
82
83
84 // 2.b.i
85 f = 70;
86 m = 24;
87 l = 100;
88
89 expect = (new Date(f, m-1, l)).toDateString();
90 actual = newDate(f, m, l).toDateString();
91 reportCompare(expect, actual, newDesc(f, m, l));
92
93 f = 99;
94 m = 12;
95 l = 1;
96
97 expect = (new Date(f, m-1, l)).toDateString();
98 actual = newDate(f, m, l).toDateString();
99 reportCompare(expect, actual, newDesc(f, m, l));
100
101 // 2.b.ii.
102
103 f = 99;
104 m = 70;
105 l = 1;
106
107 expect = true;
108 actual = isNaN(newDate(f, m, l));
109 reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');
110
111 // 2.c.i
112
113 f = 100;
114 m = 12;
115 l = 1;
116
117 expect = (new Date(f, m-1, l)).toDateString();
118 actual = newDate(f, m, l).toDateString();
119 reportCompare(expect, actual, newDesc(f, m, l));
120
121 // 2.c.ii
122
123 f = 100;
124 m = 70;
125 l = 1;
126
127 expect = true;
128 actual = isNaN(newDate(f, m, l));
129 reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');
130
131