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.23-1.js
9
ECMA Section: 15.9.5.23 Date.prototype.setTime(time)
12
1. If the this value is not a Date object, generate a runtime error.
13
2. Call ToNumber(time).
14
3. Call TimeClip(Result(1)).
15
4. Set the [[Value]] property of the this value to Result(2).
16
5. Return the value of the [[Value]] property of the this value.
18
Author: christine@netscape.com
19
Date: 12 november 1997
22
var SECTION = "15.9.5.23-1";
23
var VERSION = "ECMA_1";
25
var TITLE = "Date.prototype.setTime()";
27
writeHeaderToLog( SECTION + " Date.prototype.setTime(time)");
30
addTestCase( now, String( TZ_DIFF* msPerHour ) );
34
function addTestCase( startTime, setTime ) {
35
if ( startTime == "now" ) {
36
DateCase = new Date();
38
DateCase = new Date( startTime );
41
DateCase.setTime( setTime );
42
var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ;
43
var UTCDate = UTCDateFromTime ( Number(setTime) );
44
var LocalDate = LocalDateFromTime( Number(setTime) );
46
new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() );
47
new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() );
49
new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() );
50
new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() );
51
new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() );
52
new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() );
53
new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() );
54
new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() );
55
new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() );
56
new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() );
58
new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() );
59
new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() );
60
new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() );
61
new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() );
62
new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() );
63
new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() );
64
new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() );
65
new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() );
67
DateCase.toString = Object.prototype.toString;
69
new TestCase( SECTION,
70
DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
72
DateCase.toString() );
83
function LocalDateFromTime(t) {
85
return ( MyDateFromTime(t) );
87
function UTCDateFromTime(t) {
88
return ( MyDateFromTime(t) );
90
function MyDateFromTime( t ) {
92
d.year = YearFromTime(t);
93
d.month = MonthFromTime(t);
94
d.date = DateFromTime(t);
95
d.hours = HourFromTime(t);
96
d.minutes = MinFromTime(t);
97
d.seconds = SecFromTime(t);
99
d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
100
d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
101
d.day = WeekDay( d.value );