1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
\r
2 /* ***** BEGIN LICENSE BLOCK *****
\r
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
5 * The contents of this file are subject to the Mozilla Public License Version
\r
6 * 1.1 (the "License"); you may not use this file except in compliance with
\r
7 * the License. You may obtain a copy of the License at
\r
8 * http://www.mozilla.org/MPL/
\r
10 * Software distributed under the License is distributed on an "AS IS" basis,
\r
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
12 * for the specific language governing rights and limitations under the
\r
15 * The Original Code is Mozilla Communicator client code, released
\r
18 * The Initial Developer of the Original Code is
\r
19 * Netscape Communications Corporation.
\r
20 * Portions created by the Initial Developer are Copyright (C) 1998
\r
21 * the Initial Developer. All Rights Reserved.
\r
25 * Alternatively, the contents of this file may be used under the terms of
\r
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
\r
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
\r
28 * in which case the provisions of the GPL or the LGPL are applicable instead
\r
29 * of those above. If you wish to allow use of your version of this file only
\r
30 * under the terms of either the GPL or the LGPL, and not to allow others to
\r
31 * use your version of this file under the terms of the MPL, indicate your
\r
32 * decision by deleting the provisions above and replace them with the notice
\r
33 * and other provisions required by the GPL or the LGPL. If you do not delete
\r
34 * the provisions above, a recipient may use your version of this file under
\r
35 * the terms of any one of the MPL, the GPL or the LGPL.
\r
37 * ***** END LICENSE BLOCK ***** */
\r
40 File Name: 15.9.5.10.js
\r
41 ECMA Section: 15.9.5.10
\r
42 Description: Date.prototype.getDate
\r
44 1.Let t be this time value.
\r
45 2.If t is NaN, return NaN.
\r
46 3.Return DateFromTime(LocalTime(t)).
\r
48 Author: christine@netscape.com
\r
49 Date: 12 november 1997
\r
52 var SECTION = "15.9.5.10";
\r
53 var VERSION = "ECMA_1";
\r
55 var TITLE = "Date.prototype.getDate()";
\r
57 writeHeaderToLog( SECTION + " "+ TITLE);
\r
59 var TZ_ADJUST = TZ_DIFF * msPerHour;
\r
61 // get the current time
\r
62 var now = (new Date()).valueOf();
\r
64 // calculate time for year 0
\r
65 for ( var time = 0, year = 1969; year >= 0; year-- ) {
\r
66 time -= TimeInYear(year);
\r
68 // get time for 29 feb 2000
\r
70 var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
\r
72 // get time for 1 jan 2005
\r
74 var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
\r
75 TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
\r
77 // some daylight savings time cases
\r
79 var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
\r
81 var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
\r
85 addTestCase( time );
\r
86 addTestCase( TIME_1970 );
\r
87 addTestCase( TIME_1900 );
\r
88 addTestCase( TIME_2000 );
\r
89 addTestCase( UTC_FEB_29_2000 );
\r
90 addTestCase( UTC_JAN_1_2005 );
\r
91 addTestCase( DST_START_1998 );
\r
92 addTestCase( DST_START_1998-1 );
\r
93 addTestCase( DST_START_1998+1 );
\r
94 addTestCase( DST_END_1998 );
\r
95 addTestCase( DST_END_1998-1 );
\r
96 addTestCase( DST_END_1998+1 );
\r
99 new TestCase( SECTION,
\r
100 "(new Date(NaN)).getDate()",
\r
102 (new Date(NaN)).getDate() );
\r
104 new TestCase( SECTION,
\r
105 "Date.prototype.getDate.length",
\r
107 Date.prototype.getDate.length );
\r
110 function addTestCase( t ) {
\r
111 for ( var d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
\r
113 new TestCase( SECTION,
\r
114 "(new Date("+t+")).getDate()",
\r
115 DateFromTime(LocalTime(t)),
\r
116 (new Date(t)).getDate() );
\r