1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Date/15.9.5.5.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.9.5.5.js 1.12 + ECMA Section: 15.9.5.5 1.13 + Description: Date.prototype.getYear 1.14 + 1.15 + This function is specified here for backwards compatibility only. The 1.16 + function getFullYear is much to be preferred for nearly all purposes, 1.17 + because it avoids the "year 2000 problem." 1.18 + 1.19 + 1. Let t be this time value. 1.20 + 2. If t is NaN, return NaN. 1.21 + 3. Return YearFromTime(LocalTime(t)) 1900. 1.22 + 1.23 + Author: christine@netscape.com 1.24 + Date: 12 november 1997 1.25 +*/ 1.26 + 1.27 +var SECTION = "15.9.5.5"; 1.28 +var VERSION = "ECMA_1"; 1.29 +startTest(); 1.30 +var TITLE = "Date.prototype.getYear()"; 1.31 + 1.32 +writeHeaderToLog( SECTION + " "+ TITLE); 1.33 + 1.34 +addTestCase( TIME_NOW ); 1.35 +addTestCase( TIME_0000 ); 1.36 +addTestCase( TIME_1970 ); 1.37 +addTestCase( TIME_1900 ); 1.38 +addTestCase( TIME_2000 ); 1.39 +addTestCase( UTC_FEB_29_2000 ); 1.40 + 1.41 +new TestCase( SECTION, 1.42 + "(new Date(NaN)).getYear()", 1.43 + NaN, 1.44 + (new Date(NaN)).getYear() ); 1.45 + 1.46 +new TestCase( SECTION, 1.47 + "Date.prototype.getYear.length", 1.48 + 0, 1.49 + Date.prototype.getYear.length ); 1.50 + 1.51 +test(); 1.52 + 1.53 +function addTestCase( t ) { 1.54 + new TestCase( SECTION, 1.55 + "(new Date("+t+")).getYear()", 1.56 + GetYear(YearFromTime(LocalTime(t))), 1.57 + (new Date(t)).getYear() ); 1.58 + 1.59 + new TestCase( SECTION, 1.60 + "(new Date("+(t+1)+")).getYear()", 1.61 + GetYear(YearFromTime(LocalTime(t+1))), 1.62 + (new Date(t+1)).getYear() ); 1.63 + 1.64 + new TestCase( SECTION, 1.65 + "(new Date("+(t-1)+")).getYear()", 1.66 + GetYear(YearFromTime(LocalTime(t-1))), 1.67 + (new Date(t-1)).getYear() ); 1.68 + 1.69 + new TestCase( SECTION, 1.70 + "(new Date("+(t-TZ_ADJUST)+")).getYear()", 1.71 + GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))), 1.72 + (new Date(t-TZ_ADJUST)).getYear() ); 1.73 + 1.74 + new TestCase( SECTION, 1.75 + "(new Date("+(t+TZ_ADJUST)+")).getYear()", 1.76 + GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))), 1.77 + (new Date(t+TZ_ADJUST)).getYear() ); 1.78 +} 1.79 +function GetYear( year ) { 1.80 + return year - 1900; 1.81 +}