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.25-1.js';
42 File Name: 15.9.5.25-1.js
43 ECMA Section: 15.9.5.25 Date.prototype.setUTCMilliseconds(ms)
45 1. Let t be this time value.
47 3. Compute MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), Result(2)).
48 4. Compute MakeDate(Day(t), Result(3)).
49 5. Set the [[Value]] property of the this value to TimeClip(Result(4)).
50 6. Return the value of the [[Value]] property of the this value.
51 Author: christine@netscape.com
52 Date: 12 november 1997
54 var SECTION = "15.9.5.25-1";
55 var VERSION = "ECMA_1";
58 writeHeaderToLog( SECTION + " Date.prototype.setUTCMilliseconds(ms)");
60 addNewTestCase( 0, 0, "TDATE = new Date(0);(TDATE).setUTCMilliseconds(0);TDATE",
61 UTCDateFromTime(SetUTCMilliseconds(0,0)),
62 LocalDateFromTime(SetUTCMilliseconds(0,0)) );
63 addNewTestCase( 28800000,999,
64 "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(999);TDATE",
65 UTCDateFromTime(SetUTCMilliseconds(28800000,999)),
66 LocalDateFromTime(SetUTCMilliseconds(28800000,999)) );
67 addNewTestCase( 28800000,-28800000,
68 "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(-28800000);TDATE",
69 UTCDateFromTime(SetUTCMilliseconds(28800000,-28800000)),
70 LocalDateFromTime(SetUTCMilliseconds(28800000,-28800000)) );
71 addNewTestCase( 946684800000,1234567,
72 "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(1234567);TDATE",
73 UTCDateFromTime(SetUTCMilliseconds(946684800000,1234567)),
74 LocalDateFromTime(SetUTCMilliseconds(946684800000,1234567)) );
75 addNewTestCase( 946684800000, 123456789,
76 "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(123456789);TDATE",
77 UTCDateFromTime(SetUTCMilliseconds(946684800000,123456789)),
78 LocalDateFromTime(SetUTCMilliseconds(946684800000,123456789)) );
80 addNewTestCase( -2208988800000,123456789,
81 "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE",
82 UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)),
83 LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) );
85 addNewTestCase( -2208988800000,123456,
86 "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE",
87 UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)),
88 LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) );
90 addNewTestCase( -2208988800000,-123456,
91 "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE",
92 UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)),
93 LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) );
95 addNewTestCase( 0,-999,
96 "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE",
97 UTCDateFromTime(SetUTCMilliseconds(0,-999)),
98 LocalDateFromTime(SetUTCMilliseconds(0,-999)) );
102 function addNewTestCase( initialTime, ms, DateString, UTCDate, LocalDate) {
103 DateCase = new Date(initialTime);
104 DateCase.setUTCMilliseconds(ms);
106 new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() );
107 new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() );
109 new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() );
110 new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() );
111 new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() );
113 new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() );
114 new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() );
115 new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() );
116 new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() );
118 new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() );
119 new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() );
120 new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() );
122 new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() );
123 new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() );
124 new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() );
125 new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() );
127 DateCase.toString = Object.prototype.toString;
129 new TestCase( SECTION,
130 DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
132 DateCase.toString() );
143 function LocalDateFromTime(t) {
145 return ( MyDateFromTime(t) );
147 function UTCDateFromTime(t) {
148 return ( MyDateFromTime(t) );
150 function MyDateFromTime( t ) {
151 var d = new MyDate();
152 d.year = YearFromTime(t);
153 d.month = MonthFromTime(t);
154 d.date = DateFromTime(t);
155 d.hours = HourFromTime(t);
156 d.minutes = MinFromTime(t);
157 d.seconds = SecFromTime(t);
158 d.ms = msFromTime(t);
160 d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
161 d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
162 d.day = WeekDay( d.value );
167 function SetUTCMilliseconds( T, MS ) {
169 TIME = MakeTime( HourFromTime(T),
173 return( MakeDate( Day(T), TIME ));