1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code, released
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 gTestfile = '15.9.5.2.js';
42 File Name: 15.9.5.2.js
43 ECMA Section: 15.9.5.2 Date.prototype.toString
45 This function returns a string value. The contents of the string are
46 implementation dependent, but are intended to represent the Date in a
47 convenient, human-readable form in the current time zone.
49 The toString function is not generic; it generates a runtime error if its
50 this value is not a Date object. Therefore it cannot be transferred to
51 other kinds of objects for use as a method.
53 Author: christine@netscape.com
54 Date: 12 november 1997
57 var SECTION = "15.9.5.2";
58 var VERSION = "ECMA_1";
60 var TITLE = "Date.prototype.toString";
62 writeHeaderToLog( SECTION + " "+ TITLE);
64 new TestCase( SECTION,
65 "Date.prototype.toString.length",
67 Date.prototype.toString.length );
71 // can't test the content of the string, but can verify that the string is
72 // parsable by Date.parse
74 new TestCase( SECTION,
75 "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000",
77 Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 );
79 new TestCase( SECTION,
80 "typeof now.toString()",
82 typeof now.toString() );
85 new TestCase( SECTION,
86 "Date.parse( (new Date(0)).toString() )",
88 Date.parse( (new Date(0)).toString() ) );
90 new TestCase( SECTION,
91 "Date.parse( (new Date("+TZ_ADJUST+")).toString() )",
93 Date.parse( (new Date(TZ_ADJUST)).toString() ) );
96 new TestCase( SECTION,
97 "Date.parse( (new Date("+TIME_1900+")).toString() )",
99 Date.parse( (new Date(TIME_1900)).toString() ) );
101 new TestCase( SECTION,
102 "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )",
103 TIME_1900 -TZ_ADJUST,
104 Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) );
107 new TestCase( SECTION,
108 "Date.parse( (new Date("+TIME_2000+")).toString() )",
110 Date.parse( (new Date(TIME_2000)).toString() ) );
112 new TestCase( SECTION,
113 "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )",
114 TIME_2000 -TZ_ADJUST,
115 Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) );
119 new TestCase( SECTION,
120 "Date.parse( (new Date("+UTC_FEB_29_2000+")).toString() )",
122 Date.parse( (new Date(UTC_FEB_29_2000)).toString() ) );
124 new TestCase( SECTION,
125 "Date.parse( (new Date("+(UTC_FEB_29_2000-1000)+")).toString() )",
126 UTC_FEB_29_2000-1000,
127 Date.parse( (new Date(UTC_FEB_29_2000-1000)).toString() ) );
130 new TestCase( SECTION,
131 "Date.parse( (new Date("+(UTC_FEB_29_2000-TZ_ADJUST)+")).toString() )",
132 UTC_FEB_29_2000-TZ_ADJUST,
133 Date.parse( (new Date(UTC_FEB_29_2000-TZ_ADJUST)).toString() ) );
136 new TestCase( SECTION,
137 "Date.parse( (new Date("+UTC_JAN_1_2005+")).toString() )",
139 Date.parse( (new Date(UTC_JAN_1_2005)).toString() ) );
141 new TestCase( SECTION,
142 "Date.parse( (new Date("+(UTC_JAN_1_2005-1000)+")).toString() )",
144 Date.parse( (new Date(UTC_JAN_1_2005-1000)).toString() ) );
146 new TestCase( SECTION,
147 "Date.parse( (new Date("+(UTC_JAN_1_2005-TZ_ADJUST)+")).toString() )",
148 UTC_JAN_1_2005-TZ_ADJUST,
149 Date.parse( (new Date(UTC_JAN_1_2005-TZ_ADJUST)).toString() ) );