]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Date/15.9.5.5.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.9.5.5.js
24 ECMA Section: 15.9.5.5
25 Description: Date.prototype.getYear
27 This function is specified here for backwards compatibility only. The
28 function getFullYear is much to be preferred for nearly all purposes,
29 because it avoids the "year 2000 problem."
31 1. Let t be this time value.
32 2. If t is NaN, return NaN.
33 3. Return YearFromTime(LocalTime(t)) 1900.
35 Author: christine@netscape.com
36 Date: 12 november 1997
39 var SECTION
= "15.9.5.5";
40 var VERSION
= "ECMA_1";
42 var TITLE
= "Date.prototype.getYear()";
44 writeHeaderToLog( SECTION
+ " "+ TITLE
);
46 var testcases
= new Array();
48 var TZ_ADJUST
= TZ_DIFF
* msPerHour
;
50 // get the current time
51 var now
= (new Date()).valueOf();
53 // get time for 29 feb 2000
55 var UTC_FEB_29_2000
= TIME_2000
+ 31*msPerDay
+ 28*msPerHour
;
58 addTestCase( TIME_YEAR_0
);
59 addTestCase( TIME_1970
);
60 addTestCase( TIME_1900
);
61 addTestCase( TIME_2000
);
62 addTestCase( UTC_FEB_29_2000
);
64 testcases
[tc
++] = new TestCase( SECTION
,
65 "(new Date(NaN)).getYear()",
67 (new Date(NaN
)).getYear() );
69 testcases
[tc
++] = new TestCase( SECTION
,
70 "Date.prototype.getYear.length",
72 Date
.prototype.getYear
.length
);
75 function addTestCase( t
) {
76 testcases
[tc
++] = new TestCase( SECTION
,
77 "(new Date("+t
+")).getYear()",
78 GetYear(YearFromTime(LocalTime(t
))),
79 (new Date(t
)).getYear() );
81 testcases
[tc
++] = new TestCase( SECTION
,
82 "(new Date("+(t
+1)+")).getYear()",
83 GetYear(YearFromTime(LocalTime(t
+1))),
84 (new Date(t
+1)).getYear() );
86 testcases
[tc
++] = new TestCase( SECTION
,
87 "(new Date("+(t
-1)+")).getYear()",
88 GetYear(YearFromTime(LocalTime(t
-1))),
89 (new Date(t
-1)).getYear() );
91 testcases
[tc
++] = new TestCase( SECTION
,
92 "(new Date("+(t
-TZ_ADJUST
)+")).getYear()",
93 GetYear(YearFromTime(LocalTime(t
-TZ_ADJUST
))),
94 (new Date(t
-TZ_ADJUST
)).getYear() );
96 testcases
[tc
++] = new TestCase( SECTION
,
97 "(new Date("+(t
+TZ_ADJUST
)+")).getYear()",
98 GetYear(YearFromTime(LocalTime(t
+TZ_ADJUST
))),
99 (new Date(t
+TZ_ADJUST
)).getYear() );
101 function GetYear( year
) {
103 if ( year >= 1900 && year < 2000 ) {
112 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
113 testcases
[tc
].passed
= writeTestCaseResult(
114 testcases
[tc
].expect
,
115 testcases
[tc
].actual
,
116 testcases
[tc
].description
+" = "+
117 testcases
[tc
].actual
);
119 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
122 return ( testcases
);