1
/* The contents of this file are subject to the Netscape Public
2
* License Version 1.1 (the "License"); you may not use this file
3
* except in compliance with the License. You may obtain a copy of
4
* the License at http://www.mozilla.org/NPL/
6
* Software distributed under the License is distributed on an "AS
7
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8
* implied. See the License for the specific language governing
9
* rights and limitations under the License.
11
* The Original Code is Mozilla Communicator client code, released March
14
* The Initial Developer of the Original Code is Netscape Communications
15
* Corporation. Portions created by Netscape are
16
* Copyright (C) 1998 Netscape Communications Corporation. All
23
File Name: 15.9.5.2.js
24
ECMA Section: 15.9.5.2 Date.prototype.toString
26
This function returns a string value. The contents of the string are
27
implementation dependent, but are intended to represent the Date in a
28
convenient, human-readable form in the current time zone.
30
The toString function is not generic; it generates a runtime error if its
31
this value is not a Date object. Therefore it cannot be transferred to
32
other kinds of objects for use as a method.
34
Author: christine@netscape.com
35
Date: 12 november 1997
38
var SECTION = "15.9.5.2";
39
var VERSION = "ECMA_1";
41
var TITLE = "Date.prototype.toString";
43
writeHeaderToLog( SECTION + " "+ TITLE);
45
var testcases = new Array();
47
testcases[tc++] = new TestCase( SECTION,
48
"Date.prototype.toString.length",
50
Date.prototype.toString.length );
54
// can't test the content of the string, but can verify that the string is
55
// parsable by Date.parse
57
testcases[tc++] = new TestCase( SECTION,
58
"Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000",
60
Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 );
62
testcases[tc++] = new TestCase( SECTION,
63
"typeof now.toString()",
65
typeof now.toString() );
68
TZ_ADJUST = TZ_DIFF * msPerHour;
70
testcases[tc++] = new TestCase( SECTION,
71
"Date.parse( (new Date(0)).toString() )",
73
Date.parse( (new Date(0)).toString() ) )
75
testcases[tc++] = new TestCase( SECTION,
76
"Date.parse( (new Date("+TZ_ADJUST+")).toString() )",
78
Date.parse( (new Date(TZ_ADJUST)).toString() ) )
81
testcases[tc++] = new TestCase( SECTION,
82
"Date.parse( (new Date("+TIME_1900+")).toString() )",
84
Date.parse( (new Date(TIME_1900)).toString() ) )
86
testcases[tc++] = new TestCase( SECTION,
87
"Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )",
89
Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) )
92
testcases[tc++] = new TestCase( SECTION,
93
"Date.parse( (new Date("+TIME_2000+")).toString() )",
95
Date.parse( (new Date(TIME_2000)).toString() ) )
97
testcases[tc++] = new TestCase( SECTION,
98
"Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )",
100
Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) )
104
var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay;
105
testcases[tc++] = new TestCase( SECTION,
106
"Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )",
108
Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) )
110
testcases[tc++] = new TestCase( SECTION,
111
"Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )",
112
UTC_29_FEB_2000-1000,
113
Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) )
116
testcases[tc++] = new TestCase( SECTION,
117
"Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )",
118
UTC_29_FEB_2000-TZ_ADJUST,
119
Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) )
122
var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
123
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
124
testcases[tc++] = new TestCase( SECTION,
125
"Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )",
127
Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) )
129
testcases[tc++] = new TestCase( SECTION,
130
"Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )",
132
Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) )
134
testcases[tc++] = new TestCase( SECTION,
135
"Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )",
136
UTC_1_JAN_2005-TZ_ADJUST,
137
Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) )
141
for ( tc=0; tc < testcases.length; tc++ ) {
142
testcases[tc].passed = writeTestCaseResult(
143
testcases[tc].expect,
144
testcases[tc].actual,
145
testcases[tc].description +" = "+
146
testcases[tc].actual );
148
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
151
return ( testcases );