jscript: Support VT_DATE to number conversion.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
859783e83b
commit
3fb0e893b1
|
@ -2462,3 +2462,24 @@ HRESULT create_date_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp
|
|||
jsdisp_release(&date->dispex);
|
||||
return hres;
|
||||
}
|
||||
|
||||
HRESULT variant_date_to_number(double date, double *ret)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
UDATE udate;
|
||||
HRESULT hres;
|
||||
|
||||
hres = VarUdateFromDate(date, 0, &udate);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
if(!TzSpecificLocalTimeToSystemTime(NULL, &udate.st, &st))
|
||||
return E_FAIL;
|
||||
|
||||
TRACE("%uy %um %u %ud %uh %um %u.%us\n", st.wYear, st.wMonth, st.wDayOfWeek, st.wDay, st.wHour, st.wMinute,
|
||||
st.wSecond, st.wMilliseconds);
|
||||
|
||||
*ret = make_date(make_day(st.wYear, st.wMonth - 1, st.wDay),
|
||||
make_time(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds));
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@ HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
|
|||
HRESULT jsval_strict_equal(jsval_t,jsval_t,BOOL*) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
|
||||
HRESULT variant_date_to_number(double,double*) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
|
||||
|
||||
|
|
|
@ -611,9 +611,16 @@ HRESULT to_number(script_ctx_t *ctx, jsval_t val, double *ret)
|
|||
case JSV_BOOL:
|
||||
*ret = get_bool(val) ? 1 : 0;
|
||||
return S_OK;
|
||||
case JSV_VARIANT:
|
||||
FIXME("unimplemented for variant %s\n", debugstr_variant(get_variant(val)));
|
||||
return E_NOTIMPL;
|
||||
case JSV_VARIANT: {
|
||||
const VARIANT *v = get_variant(val);
|
||||
switch(V_VT(v)) {
|
||||
case VT_DATE:
|
||||
return variant_date_to_number(V_DATE(v), ret);
|
||||
default:
|
||||
FIXME("unimplemented for variant %s\n", debugstr_variant(v));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assert(0);
|
||||
|
|
|
@ -197,6 +197,17 @@ ok(tmp === 3, "tmp = " + tmp);
|
|||
d = v_date(0);
|
||||
e = Date.parse("Sat Dec 30 00:00:00 1899");
|
||||
ok(getVT(d) === "VT_DATE", "vt v_date(0) = " + getVT(d));
|
||||
ok(getVT(+d) === "VT_R8", "vt +v_date(0) = " + getVT(d));
|
||||
ok(getVT(d / d) === "VT_I4", "vt v_date(0) / v_date(0) = " + getVT(d / d));
|
||||
ok((+d) === e, "+v_date(0) = " + (+d) + " expected " + e);
|
||||
|
||||
d = v_date(2.5);
|
||||
e = Date.parse("Mon Jan 1 12:00:00 1900");
|
||||
ok((+d) === e, "+v_date(2.5) = " + (+d));
|
||||
|
||||
d = v_date(42091);
|
||||
e = Date.parse("Sat Mar 28 00:00:00 2015");
|
||||
ok((+d) === e, "+v_date(2015y) = " + (+d) + " expected " + e);
|
||||
})();
|
||||
|
||||
function testRecFunc(x) {
|
||||
|
|
Loading…
Reference in New Issue