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/. */
8
File Name: 15.9.5.24-1.js
9
ECMA Section: 15.9.5.24 Date.prototype.setTime(time)
11
1. If the this value is not a Date object, generate a runtime error.
12
2. Call ToNumber(time).
13
3. Call TimeClip(Result(1)).
14
4. Set the [[Value]] property of the this value to Result(2).
15
5. Return the value of the [[Value]] property of the this value.
16
Author: christine@netscape.com
17
Date: 12 november 1997
20
var TITLE = "Date.prototype.setTime"
21
var SECTION = "15.9.5.24-1";
22
var VERSION = "ECMA_1";
25
writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)");
28
addTestCase( 0, "-2208988800000" );
32
function addTestCase( startms, newms ) {
34
var DateCase = new Date( startms );
35
DateCase.setMilliseconds( newms );
36
var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date";
37
var UTCDate = UTCDateFromTime( Number(newms) );
38
var LocalDate = LocalDateFromTime( Number(newms) );
40
new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() );
41
new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() );
43
new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() );
44
new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() );
45
new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() );
47
new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() );
48
new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() );
49
new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() );
50
new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() );
52
new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() );
53
new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() );
54
new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() );
56
new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() );
57
new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() );
58
new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() );
59
new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() );
61
DateCase.toString = Object.prototype.toString;
63
new TestCase( SECTION,
64
DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
66
DateCase.toString() );
78
function LocalDateFromTime(t) {
80
return ( MyDateFromTime(t) );
82
function UTCDateFromTime(t) {
83
return ( MyDateFromTime(t) );
85
function MyDateFromTime( t ) {
87
d.year = YearFromTime(t);
88
d.month = MonthFromTime(t);
89
d.date = DateFromTime(t);
90
d.hours = HourFromTime(t);
91
d.minutes = MinFromTime(t);
92
d.seconds = SecFromTime(t);
95
d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
96
d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
97
d.day = WeekDay( d.value );