Implement builtin getters for Date object

JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan szledan.u-szeged@partner.samsung.com
This commit is contained in:
Szilard Ledan 2015-06-24 11:06:08 +02:00
parent 6547cf3b2d
commit 8d7cdebee0
5 changed files with 272 additions and 278 deletions

View File

@ -15,8 +15,12 @@
*/
#include "ecma-alloc.h"
#include "ecma-builtin-helpers.h"
#include "ecma-exceptions.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-try-catch-macro.h"
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN
@ -139,7 +143,7 @@ ecma_builtin_date_prototype_to_locale_time_string (ecma_value_t this_arg) /**< t
static ecma_completion_value_t
ecma_builtin_date_prototype_value_of (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
return ecma_builtin_date_prototype_get_time (this_arg);
} /* ecma_builtin_date_prototype_value_of */
/**
@ -154,263 +158,93 @@ ecma_builtin_date_prototype_value_of (ecma_value_t this_arg) /**< this argument
static ecma_completion_value_t
ecma_builtin_date_prototype_get_time (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
if (ecma_is_value_object (this_arg))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
if (ecma_object_get_class_name (obj_p) == LIT_MAGIC_STRING_DATE_UL)
{
ecma_property_t *prim_value_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE);
ecma_number_t *prim_value_num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
prim_value_prop_p->u.internal_property.value);
ecma_number_t *ret_num_p = ecma_alloc_number ();
*ret_num_p = *prim_value_num_p;
return ecma_make_normal_completion_value (ecma_make_number_value (ret_num_p));
}
}
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
} /* ecma_builtin_date_prototype_get_time */
/**
* The Date.prototype object's 'getFullYear' routine
*
* See also:
* ECMA-262 v5, 15.9.5.10
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
* Helper macro, define the getter function argument to use
* UTC time, passing the argument as is.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_full_year (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_full_year */
#define DEFINE_GETTER_ARGUMENT_utc(this_num) (this_num)
/**
* The Date.prototype object's 'getUTCFullYear' routine
*
* See also:
* ECMA-262 v5, 15.9.5.11
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
* Helper macro, define the getter function argument to use
* local time, passing the argument to 'ecma_date_local_time' function.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_full_year (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_full_year */
#define DEFINE_GETTER_ARGUMENT_local(this_num) (ecma_date_local_time (this_num))
/**
* The Date.prototype object's 'getMonth' routine
*
* See also:
* ECMA-262 v5, 15.9.5.12
* Implementation of Data.prototype built-in's getter routines
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_month (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_month */
#define DEFINE_GETTER(_ecma_paragraph, _routine_name, _getter_name, _timezone) \
static ecma_completion_value_t \
ecma_builtin_date_prototype_get_ ## _routine_name (ecma_value_t this_arg) /**< this argument */ \
{ \
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); \
\
/* 1. */ \
ECMA_TRY_CATCH (value, ecma_builtin_date_prototype_get_time (this_arg), ret_value); \
ecma_number_t *this_num_p = ecma_get_number_from_value (value); \
/* 2. */ \
if (ecma_number_is_nan (*this_num_p)) \
{ \
ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN); \
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (nan_str_p)); \
} \
else \
{ \
/* 3. */ \
ecma_number_t *ret_num_p = ecma_alloc_number (); \
*ret_num_p = _getter_name (DEFINE_GETTER_ARGUMENT_ ## _timezone (*this_num_p)); \
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (ret_num_p)); \
} \
ECMA_FINALIZE (value); \
\
return ret_value; \
}
/**
* The Date.prototype object's 'getUTCMonth' routine
*
* See also:
* ECMA-262 v5, 15.9.5.13
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_month (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_month */
DEFINE_GETTER (ECMA-262 v5 15.9.5.10, full_year, ecma_date_year_from_time, local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.11, utc_full_year, ecma_date_year_from_time, utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.12, month, ecma_date_month_from_time, local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.13, utc_month, ecma_date_month_from_time, utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.14, date, ecma_date_date_from_time, local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.15, utc_date, ecma_date_date_from_time, utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.16, day, ecma_date_week_day, local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.17, utc_day, ecma_date_week_day, utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.18, hours, ecma_date_hour_from_time, local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.19, utc_hours, ecma_date_hour_from_time, utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.20, minutes, ecma_date_min_from_time, local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.21, utc_minutes, ecma_date_min_from_time, utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.22, seconds, ecma_date_sec_from_time, local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.23, utc_seconds, ecma_date_sec_from_time, utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.24, milliseconds, ecma_date_ms_from_time , local)
DEFINE_GETTER (ECMA-262 v5 15.9.5.25, utc_milliseconds, ecma_date_ms_from_time , utc)
DEFINE_GETTER (ECMA-262 v5 15.9.5.26, timezone_offset, ecma_date_timezone_offset, utc)
/**
* The Date.prototype object's 'getDate' routine
*
* See also:
* ECMA-262 v5, 15.9.5.14
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_date (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_date */
/**
* The Date.prototype object's 'getUTCDate' routine
*
* See also:
* ECMA-262 v5, 15.9.5.15
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_date (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_date */
/**
* The Date.prototype object's 'getDay' routine
*
* See also:
* ECMA-262 v5, 15.9.5.16
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_day (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_day */
/**
* The Date.prototype object's 'getUTCDay' routine
*
* See also:
* ECMA-262 v5, 15.9.5.17
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_day (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_day */
/**
* The Date.prototype object's 'getHours' routine
*
* See also:
* ECMA-262 v5, 15.9.5.18
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_hours (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_hours */
/**
* The Date.prototype object's 'getUTCHours' routine
*
* See also:
* ECMA-262 v5, 15.9.5.19
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_hours (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_hours */
/**
* The Date.prototype object's 'getMinutes' routine
*
* See also:
* ECMA-262 v5, 15.9.5.20
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_minutes (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_minutes */
/**
* The Date.prototype object's 'getUTCMinutes' routine
*
* See also:
* ECMA-262 v5, 15.9.5.21
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_minutes (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_minutes */
/**
* The Date.prototype object's 'getSeconds' routine
*
* See also:
* ECMA-262 v5, 15.9.5.22
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_seconds (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_seconds */
/**
* The Date.prototype object's 'getUTCSeconds' routine
*
* See also:
* ECMA-262 v5, 15.9.5.23
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_seconds (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_seconds */
/**
* The Date.prototype object's 'getMilliseconds' routine
*
* See also:
* ECMA-262 v5, 15.9.5.24
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_milliseconds (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_milliseconds */
/**
* The Date.prototype object's 'getUTCMilliseconds' routine
*
* See also:
* ECMA-262 v5, 15.9.5.25
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_utc_milliseconds (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_utc_milliseconds */
/**
* The Date.prototype object's 'getTimezoneOffset' routine
*
* See also:
* ECMA-262 v5, 15.9.5.26
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_date_prototype_get_timezone_offset (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_date_prototype_get_timezone_offset */
#undef DEFINE_GETTER_ARGUMENT_utc
#undef DEFINE_GETTER_ARGUMENT_local
#undef DEFINE_GETTER
/**
* The Date.prototype object's 'setTime' routine

View File

@ -28,31 +28,6 @@
* @{
*/
/**
* Time range defines for helper functions.
*
* See also:
* ECMA-262 v5, 15.9.1.1, 15.9.1.10
*/
/* Hours in a day. */
#define ECMA_DATE_HOURS_PER_DAY 24
/* Minutes in an hour. */
#define ECMA_DATE_MINUTES_PER_HOUR 60
/* Seconds in a minute. */
#define ECMA_DATE_SECONDS_PER_MINUTE 60
/* Milliseconds in a second. */
#define ECMA_DATE_MS_PER_SECOND 1000
/* ECMA_DATE_MS_PER_MINUTE == 60000 */
#define ECMA_DATE_MS_PER_MINUTE (ECMA_DATE_MS_PER_SECOND * ECMA_DATE_SECONDS_PER_MINUTE)
/* ECMA_DATE_MS_PER_HOUR == 3600000 */
#define ECMA_DATE_MS_PER_HOUR (ECMA_DATE_MS_PER_MINUTE * ECMA_DATE_MINUTES_PER_HOUR)
/* ECMA_DATE_MS_PER_DAY == 86400000 */
#define ECMA_DATE_MS_PER_DAY (ECMA_DATE_MS_PER_HOUR * ECMA_DATE_HOURS_PER_DAY)
/* This gives a range of 8,640,000,000,000,000 milliseconds
* to either side of 01 January, 1970 UTC.
*/
#define ECMA_DATE_MAX_VALUE 8.64e15
/**
* Helper function to get day number from time value.
*
@ -172,6 +147,10 @@ ecma_date_time_from_year (ecma_number_t year) /**< year value */
* See also:
* ECMA-262 v5, 15.9.1.3
*
* Used by:
* - The Date.prototype.getFullYear routine. (Generated.)
* - The Date.prototype.getUTCFullYear routine. (Generated.)
*
* @return year value
*/
ecma_number_t
@ -243,6 +222,10 @@ ecma_date_day_within_year (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.4
*
* Used by:
* - The Date.prototype.getMonth routine. (Generated.)
* - The Date.prototype.getUTCMonth routine. (Generated.)
*
* @return month number
*/
ecma_number_t
@ -312,6 +295,10 @@ ecma_date_month_from_time (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.5
*
* Used by:
* - The Date.prototype.getDate routine. (Generated.)
* - The Date.prototype.getUTCDate routine. (Generated.)
*
* @return date number
*/
ecma_number_t
@ -389,6 +376,10 @@ ecma_date_date_from_time (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.6
*
* Used by:
* - The Date.prototype.getDay routine. (Generated.)
* - The Date.prototype.getUTCDay routine. (Generated.)
*
* @return weekday number
*/
ecma_number_t __attr_always_inline___
@ -451,6 +442,10 @@ ecma_date_daylight_saving_ta (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.9
*
* Used by:
* - All Date.prototype.getUTC* routines. (Generated.)
* - The Date.prototype.getTimezoneOffset routine.
*
* @return local time
*/
ecma_number_t __attr_always_inline___
@ -490,6 +485,10 @@ ecma_date_utc (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.10
*
* Used by:
* - The Date.prototype.getHour routine. (Generated.)
* - The Date.prototype.getUTCHour routine. (Generated.)
*
* @return hour value
*/
ecma_number_t __attr_always_inline___
@ -510,6 +509,10 @@ ecma_date_hour_from_time (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.10
*
* Used by:
* - The Date.prototype.getMinutes routine. (Generated.)
* - The Date.prototype.getUTCMinutes routine. (Generated.)
*
* @return minute value
*/
ecma_number_t __attr_always_inline___
@ -530,6 +533,10 @@ ecma_date_min_from_time (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.10
*
* Used by:
* - The Date.prototype.getSeconds routine. (Generated.)
* - The Date.prototype.getUTCSeconds routine. (Generated.)
*
* @return second value
*/
ecma_number_t __attr_always_inline___
@ -550,6 +557,10 @@ ecma_date_sec_from_time (ecma_number_t time) /**< time value */
* See also:
* ECMA-262 v5, 15.9.1.10
*
* Used by:
* - The Date.prototype.getMilliseconds routine. (Generated.)
* - The Date.prototype.getUTCMilliseconds routine. (Generated.)
*
* @return millisecond value
*/
ecma_number_t __attr_always_inline___
@ -688,6 +699,28 @@ ecma_date_time_clip (ecma_number_t time) /**< time value */
return ecma_number_trunc (time);
} /* ecma_date_time_clip */
/**
* Helper function to calculate timezone offset.
*
* See also:
* ECMA-262 v5, 15.9.5.26
*
* Used by:
* - The Date.prototype.getTimezoneOffset routine. (Generated.)
*
* @return timezone offset
*/
ecma_number_t __attr_always_inline___
ecma_date_timezone_offset (ecma_number_t time) /**< time value */
{
if (ecma_number_is_nan (time))
{
return ecma_number_make_nan ();
}
return (time - ecma_date_local_time (time)) / ECMA_DATE_MS_PER_MINUTE;
} /* ecma_date_timezone_offset */
/**
* @}
* @}

View File

@ -34,6 +34,32 @@ extern uint32_t ecma_builtin_helper_array_index_normalize (ecma_number_t index,
extern uint32_t ecma_builtin_helper_string_index_normalize (ecma_number_t index, uint32_t length);
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN
/**
* Time range defines for helper functions.
*
* See also:
* ECMA-262 v5, 15.9.1.1, 15.9.1.10
*/
/* Hours in a day. */
#define ECMA_DATE_HOURS_PER_DAY 24
/* Minutes in an hour. */
#define ECMA_DATE_MINUTES_PER_HOUR 60
/* Seconds in a minute. */
#define ECMA_DATE_SECONDS_PER_MINUTE 60
/* Milliseconds in a second. */
#define ECMA_DATE_MS_PER_SECOND 1000
/* ECMA_DATE_MS_PER_MINUTE == 60000 */
#define ECMA_DATE_MS_PER_MINUTE (ECMA_DATE_MS_PER_SECOND * ECMA_DATE_SECONDS_PER_MINUTE)
/* ECMA_DATE_MS_PER_HOUR == 3600000 */
#define ECMA_DATE_MS_PER_HOUR (ECMA_DATE_MS_PER_MINUTE * ECMA_DATE_MINUTES_PER_HOUR)
/* ECMA_DATE_MS_PER_DAY == 86400000 */
#define ECMA_DATE_MS_PER_DAY (ECMA_DATE_MS_PER_HOUR * ECMA_DATE_HOURS_PER_DAY)
/* This gives a range of 8,640,000,000,000,000 milliseconds
* to either side of 01 January, 1970 UTC.
*/
#define ECMA_DATE_MAX_VALUE 8.64e15
/* ecma-builtin-helpers-date.cpp */
extern ecma_number_t ecma_date_day (ecma_number_t time);
extern ecma_number_t ecma_date_time_within_day (ecma_number_t time);
@ -63,6 +89,7 @@ extern ecma_number_t ecma_date_make_day (ecma_number_t year,
ecma_number_t date);
extern ecma_number_t ecma_date_make_date (ecma_number_t day, ecma_number_t time);
extern ecma_number_t ecma_date_time_clip (ecma_number_t time);
extern ecma_number_t ecma_date_timezone_offset (ecma_number_t time);
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN */
typedef struct

View File

@ -29,29 +29,29 @@ catch (e)
assert (e.message === "foo");
}
// FIXME: Add assert statements when getters for Date are finished.
d = Date("abcd");
// assert (isNaN(d.valueOf()));
assert (isNaN(d.valueOf()));
d = Date();
// assert (!isNaN(d.valueOf()));
assert (!isNaN(d.valueOf()));
d = Date("2015-01-01");
// assert (d.valueOf() == 1420070400000);
assert (d.valueOf() == 1420070400000);
d = Date(1420070400000);
// assert (d.valueOf() == 1420070400000);
assert (d.valueOf() == 1420070400000);
d = Date(2015,0,1,0,0,0,0);
// assert (d.valueOf() == 1420070400000);
assert (d.valueOf() == 1420070400000);
d = new Date();
// assert (isNaN(d.valueOf()));
assert (!isNaN(d.valueOf()));
d = new Date("2015-01-01");
// assert (d.valueOf() == 1420070400000);
assert (d.valueOf() == 1420070400000);
d = new Date(1420070400000);
// assert (d.valueOf() == 1420070400000);
assert (d.valueOf() == 1420070400000);
d = new Date(2015,0,1,0,0,0,0);
// assert (d.valueOf() == 1420070400000);
assert (d.valueOf() == 1420070400000);

100
tests/jerry/date-getters.js Normal file
View File

@ -0,0 +1,100 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/* 1. test case */
var d = new Date(2015, 6, 9, 12, 13, 14, 121);
assert (d.getFullYear() == 2015);
assert (d.getUTCFullYear() == 2015);
assert (d.getMonth() == 6);
assert (d.getUTCMonth() == 6);
assert (d.getDate() == 9);
assert (d.getUTCDate() == 9);
assert (d.getDay() == 4);
assert (d.getUTCDay() == 4);
assert (d.getHours() == 12);
// FIXME: Missing timezone adjustment.
//assert (d.getUTCHours() == (12 + d.getTimezoneOffset() / 60));
assert (d.getMinutes() == 13);
assert (d.getUTCMinutes() == 13);
assert (d.getSeconds() == 14);
assert (d.getUTCSeconds() == 14);
assert (d.getMilliseconds() == 121);
assert (d.getUTCMilliseconds() == 121);
/* 2. test case */
var d = new Date("2015-07-09T12:13:14.121+01:30");
assert (d.getFullYear() == 2015);
assert (d.getUTCFullYear() == 2015);
assert (d.getMonth() == 6);
assert (d.getUTCMonth() == 6);
assert (d.getDate() == 9);
assert (d.getUTCDate() == 9);
assert (d.getDay() == 4);
assert (d.getUTCDay() == 4);
// FIXME: Missing timezone adjustment.
//assert (d.getHours() == 12);
//assert (d.getUTCHours() == (12 + d.getTimezoneOffset() / 60));
assert (d.getMinutes() == 43);
assert (d.getUTCMinutes() == 43);
assert (d.getSeconds() == 14);
assert (d.getUTCSeconds() == 14);
assert (d.getMilliseconds() == 121);
assert (d.getUTCMilliseconds() == 121);
/* 3. test case */
var d = new Date(0);
assert (d.getFullYear() == 1970);
assert (d.getUTCFullYear() == 1970);
assert (d.getMonth() == 0);
assert (d.getUTCMonth() == 0);
assert (d.getDate() == 1);
assert (d.getUTCDate() == 1);
assert (d.getDay() == 4);
assert (d.getUTCDay() == 4);
// FIXME: Missing timezone adjustment.
// assert (d.getHours() == 0 - (d.getTimezoneOffset() / 60));
assert (d.getUTCHours() == 0);
assert (d.getMinutes() == 0);
assert (d.getUTCMinutes() == 0);
assert (d.getSeconds() == 0);
assert (d.getUTCSeconds() == 0);
assert (d.getMilliseconds() == 0);
assert (d.getUTCMilliseconds() == 0);
/* 4. test case */
var d = new Date("abcd");
assert (isNaN (d));
assert (isNaN (d.getFullYear()));
assert (isNaN (d.getUTCFullYear()));
assert (isNaN (d.getMonth()));
assert (isNaN (d.getUTCMonth()));
assert (isNaN (d.getDate()));
assert (isNaN (d.getUTCDate()));
assert (isNaN (d.getDay()));
assert (isNaN (d.getUTCDay()));
assert (isNaN (d.getHours()));
assert (isNaN (d.getUTCHours()));
assert (isNaN (d.getMinutes()));
assert (isNaN (d.getUTCMinutes()));
assert (isNaN (d.getSeconds()));
assert (isNaN (d.getUTCSeconds()));
assert (isNaN (d.getMilliseconds()));
assert (isNaN (d.getUTCMilliseconds()));
assert (isNaN (d.getTimezoneOffset()));