Commit 42c044ae authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Support VT_DATE to string conversion.

parent 3fb0e893
......@@ -2483,3 +2483,28 @@ HRESULT variant_date_to_number(double date, double *ret)
make_time(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds));
return S_OK;
}
HRESULT variant_date_to_string(script_ctx_t *ctx, double date, jsstr_t **r)
{
DateInstance *date_obj;
jsval_t val;
double time;
HRESULT hres;
hres = variant_date_to_number(date, &time);
if(FAILED(hres))
return hres;
hres = create_date(ctx, NULL, time, &date_obj);
if(FAILED(hres))
return hres;
hres = dateobj_to_string(date_obj, &val);
jsdisp_release(&date_obj->dispex);
if(FAILED(hres))
return hres;
assert(is_string(val));
*r = get_string(val);
return hres;
}
......@@ -361,6 +361,7 @@ 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 variant_date_to_string(script_ctx_t*,double,jsstr_t**) DECLSPEC_HIDDEN;
HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
......
......@@ -773,9 +773,17 @@ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsstr_t **str)
case JSV_BOOL:
*str = jsstr_alloc(get_bool(val) ? L"true" : L"false");
break;
default:
FIXME("unsupported %s\n", debugstr_jsval(val));
return E_NOTIMPL;
default: {
const VARIANT *v = get_variant(val);
switch(V_VT(v))
{
case VT_DATE:
return variant_date_to_string(ctx, V_DATE(v), str);
default:
FIXME("unsupported %s\n", debugstr_variant(v));
return E_NOTIMPL;
}
}
}
return *str ? S_OK : E_OUTOFMEMORY;
......
......@@ -200,14 +200,17 @@ ok(tmp === 3, "tmp = " + tmp);
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);
ok(("" + d).match(/^Sat Dec 30 00:00:00 .* 1899$/) != null, "+v_date(0) = " + d);
d = v_date(2.5);
e = Date.parse("Mon Jan 1 12:00:00 1900");
ok((+d) === e, "+v_date(2.5) = " + (+d));
ok(("" + d).match(/^Mon Jan 1 12:00:00 .* 1900$/) != null, "+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);
ok(("" + d).match(/^Sat Mar 28 00:00:00 .* 2015$/) != null, "+v_date(2015y) = " + d);
})();
function testRecFunc(x) {
......
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