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/. */
9
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
10
Description: The [[Prototype]] property of the newly constructed
11
object is set to the original Date prototype object,
12
the one that is the initial value of Date.prototype.
14
The [[Class]] property of the newly constructed object
16
1. Call ToNumber(year)
17
2. Call ToNumber(month)
18
3. Call ToNumber(date)
19
4. Call ToNumber(hours)
20
5. Call ToNumber(minutes)
21
6. Call ToNumber(seconds)
23
8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
24
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
25
Result(8) is Result(1)
26
9. Compute MakeDay(Result(8), Result(2), Result(3)
27
10. Compute MakeTime(Result(4), Result(5), Result(6),
29
11. Compute MakeDate(Result(9), Result(10))
30
12. Set the [[Value]] property of the newly constructed
31
object to TimeClip(UTC(Result(11))).
34
This tests the returned value of a newly constructed
37
Author: christine@netscape.com
41
var SECTION = "15.9.3.1";
42
var VERSION = "ECMA_1";
44
var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )";
65
writeHeaderToLog( SECTION + " "+ TITLE);
67
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
71
addNewTestCase( new Date(1899,11,31,16,0,0,0),
72
"new Date(1899,11,31,16,0,0,0)",
73
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
75
addNewTestCase( new Date(1899,11,31,15,59,59,999),
76
"new Date(1899,11,31,15,59,59,999)",
77
[TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
79
addNewTestCase( new Date(1899,11,31,23,59,59,999),
80
"new Date(1899,11,31,23,59,59,999)",
81
[TIME_1900-PST_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] );
83
addNewTestCase( new Date(1900,0,1,0,0,0,0),
84
"new Date(1900,0,1,0,0,0,0)",
85
[TIME_1900-PST_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
87
addNewTestCase( new Date(1900,0,1,0,0,0,1),
88
"new Date(1900,0,1,0,0,0,1)",
89
[TIME_1900-PST_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
93
function addNewTestCase( DateCase, DateString, ResultArray ) {
94
//adjust hard-coded ResultArray for tester's timezone instead of PST
95
adjustResultArray(ResultArray);
97
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
98
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
100
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
101
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
102
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
103
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
104
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
105
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
106
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
107
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
109
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
110
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
111
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
112
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
113
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
114
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
115
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
116
new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );