Debian Codegraph @

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