|
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 /** |
|
8 File Name: 15.9.5.5.js |
|
9 ECMA Section: 15.9.5.5 |
|
10 Description: Date.prototype.getYear |
|
11 |
|
12 This function is specified here for backwards compatibility only. The |
|
13 function getFullYear is much to be preferred for nearly all purposes, |
|
14 because it avoids the "year 2000 problem." |
|
15 |
|
16 1. Let t be this time value. |
|
17 2. If t is NaN, return NaN. |
|
18 3. Return YearFromTime(LocalTime(t)) 1900. |
|
19 |
|
20 Author: christine@netscape.com |
|
21 Date: 12 november 1997 |
|
22 */ |
|
23 |
|
24 var SECTION = "15.9.5.5"; |
|
25 var VERSION = "ECMA_1"; |
|
26 startTest(); |
|
27 var TITLE = "Date.prototype.getYear()"; |
|
28 |
|
29 writeHeaderToLog( SECTION + " "+ TITLE); |
|
30 |
|
31 addTestCase( TIME_NOW ); |
|
32 addTestCase( TIME_0000 ); |
|
33 addTestCase( TIME_1970 ); |
|
34 addTestCase( TIME_1900 ); |
|
35 addTestCase( TIME_2000 ); |
|
36 addTestCase( UTC_FEB_29_2000 ); |
|
37 |
|
38 new TestCase( SECTION, |
|
39 "(new Date(NaN)).getYear()", |
|
40 NaN, |
|
41 (new Date(NaN)).getYear() ); |
|
42 |
|
43 new TestCase( SECTION, |
|
44 "Date.prototype.getYear.length", |
|
45 0, |
|
46 Date.prototype.getYear.length ); |
|
47 |
|
48 test(); |
|
49 |
|
50 function addTestCase( t ) { |
|
51 new TestCase( SECTION, |
|
52 "(new Date("+t+")).getYear()", |
|
53 GetYear(YearFromTime(LocalTime(t))), |
|
54 (new Date(t)).getYear() ); |
|
55 |
|
56 new TestCase( SECTION, |
|
57 "(new Date("+(t+1)+")).getYear()", |
|
58 GetYear(YearFromTime(LocalTime(t+1))), |
|
59 (new Date(t+1)).getYear() ); |
|
60 |
|
61 new TestCase( SECTION, |
|
62 "(new Date("+(t-1)+")).getYear()", |
|
63 GetYear(YearFromTime(LocalTime(t-1))), |
|
64 (new Date(t-1)).getYear() ); |
|
65 |
|
66 new TestCase( SECTION, |
|
67 "(new Date("+(t-TZ_ADJUST)+")).getYear()", |
|
68 GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))), |
|
69 (new Date(t-TZ_ADJUST)).getYear() ); |
|
70 |
|
71 new TestCase( SECTION, |
|
72 "(new Date("+(t+TZ_ADJUST)+")).getYear()", |
|
73 GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))), |
|
74 (new Date(t+TZ_ADJUST)).getYear() ); |
|
75 } |
|
76 function GetYear( year ) { |
|
77 return year - 1900; |
|
78 } |