Commit b0915dfb authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

vbscript: Implement FormatDateTime().

parent fd6cf181
......@@ -3015,10 +3015,32 @@ static HRESULT Global_FormatPercent(BuiltinDisp *This, VARIANT *args, unsigned a
return return_bstr(res, str);
}
static HRESULT Global_FormatDateTime(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
static HRESULT Global_FormatDateTime(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
int format = 0;
HRESULT hres;
BSTR str;
TRACE("\n");
assert(1 <= args_cnt && args_cnt <= 2);
if (V_VT(args) == VT_NULL)
return MAKE_VBSERROR(VBSE_TYPE_MISMATCH);
if (args_cnt == 2)
{
if (V_VT(args+1) == VT_NULL) return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
if (V_VT(args+1) != VT_ERROR)
{
if (FAILED(hres = to_int(args+1, &format))) return hres;
}
}
hres = VarFormatDateTime(args, format, 0, &str);
if (FAILED(hres)) return hres;
return return_bstr(res, str);
}
static HRESULT Global_WeekdayName(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
......
......@@ -2411,4 +2411,29 @@ end sub
call testFormatPercent()
call testFormatPercentError()
sub testFormatDateTimeError()
on error resume next
dim x
call Err.clear()
x = FormatDateTime(null)
call ok(Err.number = 13, "Err.number = " & Err.number)
call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x))
call Err.clear()
x = FormatDateTime(.10,null)
call ok(Err.number = 94, "Err.number = " & Err.number)
call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x))
end sub
sub testFormatDateTime()
dim x
x = FormatDateTime(0)
call ok(getVT(x) = "VT_BSTR*", "getVT = " & getVT(x))
x = FormatDateTime(0.1,1)
call ok(getVT(x) = "VT_BSTR*", "getVT = " & getVT(x))
end sub
call testFormatDateTime()
call testFormatDateTimeError()
Call reportSuccess()
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