Commit 305aee06 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

jscript: Added Date_getTimezoneOffset and fixed Date_get... functions.

parent b529cdb6
...@@ -315,6 +315,12 @@ static inline DOUBLE daylight_saving_ta(DOUBLE time, DateInstance *date) ...@@ -315,6 +315,12 @@ static inline DOUBLE daylight_saving_ta(DOUBLE time, DateInstance *date)
} }
/* ECMA-262 3rd Edition 15.9.1.9 */ /* ECMA-262 3rd Edition 15.9.1.9 */
static inline DOUBLE local_time(DOUBLE time, DateInstance *date)
{
return time - (daylight_saving_ta(time, date)+date->bias)*MS_PER_MINUTE;
}
/* ECMA-262 3rd Edition 15.9.1.9 */
static inline DOUBLE utc(DOUBLE time, DateInstance *date) static inline DOUBLE utc(DOUBLE time, DateInstance *date)
{ {
time += date->bias * MS_PER_MINUTE; time += date->bias * MS_PER_MINUTE;
...@@ -525,7 +531,7 @@ static HRESULT Date_getFullYear(DispatchEx *dispex, LCID lcid, WORD flags, DISPP ...@@ -525,7 +531,7 @@ static HRESULT Date_getFullYear(DispatchEx *dispex, LCID lcid, WORD flags, DISPP
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, year_from_time(time)); num_set_val(retv, year_from_time(time));
} }
...@@ -563,7 +569,7 @@ static HRESULT Date_getMonth(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA ...@@ -563,7 +569,7 @@ static HRESULT Date_getMonth(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, month_from_time(time)); num_set_val(retv, month_from_time(time));
} }
...@@ -601,7 +607,7 @@ static HRESULT Date_getDate(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM ...@@ -601,7 +607,7 @@ static HRESULT Date_getDate(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, date_from_time(time)); num_set_val(retv, date_from_time(time));
} }
...@@ -639,7 +645,7 @@ static HRESULT Date_getDay(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS ...@@ -639,7 +645,7 @@ static HRESULT Date_getDay(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, week_day(time)); num_set_val(retv, week_day(time));
} }
...@@ -677,7 +683,7 @@ static HRESULT Date_getHours(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA ...@@ -677,7 +683,7 @@ static HRESULT Date_getHours(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, hour_from_time(time)); num_set_val(retv, hour_from_time(time));
} }
...@@ -715,7 +721,7 @@ static HRESULT Date_getMinutes(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA ...@@ -715,7 +721,7 @@ static HRESULT Date_getMinutes(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, min_from_time(time)); num_set_val(retv, min_from_time(time));
} }
...@@ -753,7 +759,7 @@ static HRESULT Date_getSeconds(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA ...@@ -753,7 +759,7 @@ static HRESULT Date_getSeconds(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, sec_from_time(time)); num_set_val(retv, sec_from_time(time));
} }
...@@ -791,7 +797,7 @@ static HRESULT Date_getMilliseconds(DispatchEx *dispex, LCID lcid, WORD flags, D ...@@ -791,7 +797,7 @@ static HRESULT Date_getMilliseconds(DispatchEx *dispex, LCID lcid, WORD flags, D
if(retv) { if(retv) {
DateInstance *date = (DateInstance*)dispex; DateInstance *date = (DateInstance*)dispex;
DOUBLE time = date->time - date->bias*MS_PER_MINUTE; DOUBLE time = local_time(date->time, date);
num_set_val(retv, ms_from_time(time)); num_set_val(retv, ms_from_time(time));
} }
...@@ -819,8 +825,19 @@ static HRESULT Date_getUTCMilliseconds(DispatchEx *dispex, LCID lcid, WORD flags ...@@ -819,8 +825,19 @@ static HRESULT Date_getUTCMilliseconds(DispatchEx *dispex, LCID lcid, WORD flags
static HRESULT Date_getTimezoneOffset(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, static HRESULT Date_getTimezoneOffset(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{ {
FIXME("\n"); TRACE("\n");
return E_NOTIMPL;
if(!is_class(dispex, JSCLASS_DATE)) {
FIXME("throw TypeError\n");
return E_FAIL;
}
if(retv) {
DateInstance *date = (DateInstance*)dispex;
num_set_val(retv, floor(
(date->time-local_time(date->time, date))/MS_PER_MINUTE));
}
return S_OK;
} }
static HRESULT Date_setTime(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, static HRESULT Date_setTime(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
......
...@@ -940,6 +940,22 @@ date = new Date(8.64e15+1); ...@@ -940,6 +940,22 @@ date = new Date(8.64e15+1);
ok(isNaN(0+date.getTime()), "date.getTime() is not NaN"); ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
date = new Date(Infinity); date = new Date(Infinity);
ok(isNaN(0+date.getTime()), "date.getTime() is not NaN"); ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
date = new Date(1984, 11, 29, 13, 51, 24, 120);
ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
date = new Date(731, -32, 40, -1, 70, 65, -13);
ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
ok(date.setTime(123) === 123, "date.setTime(123) !== 123"); ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123"); ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment