Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/vbscript/global.c | 3 +++ dlls/vbscript/tests/api.vbs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 80348a5288f..876a41a14b2 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2897,6 +2897,9 @@ static HRESULT Global_MonthName(BuiltinDisp *This, VARIANT *args, unsigned args_
assert(args_cnt == 1 || args_cnt == 2);
+ if(V_VT(args) == VT_NULL || (args_cnt == 2 && V_VT(args+1) == VT_NULL)) + return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE); + hres = to_int(args, &month); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index 617589053c6..758013c93ef 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -2148,4 +2148,21 @@ call testWeekday(DateSerial(2000, 1, 1), vbFriday, 2) call testWeekday(DateSerial(2000, 1, 1), vbSaturday, 1) call testWeekdayError()
+sub testMonthNameError() + on error resume next + call Err.clear() + call MonthName(null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call Err.clear() + call MonthName(1, null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call Err.clear() + call MonthName(null, null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call Err.clear() + call MonthName("a", null) + call ok(Err.number = 94, "Err.number = " & Err.number) +end sub +call testMonthNameError() + Call reportSuccess()
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/vbscript/global.c | 37 ++++++++++++++++++++++++++++++++++--- dlls/vbscript/tests/api.vbs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 876a41a14b2..90cfd557038 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2144,10 +2144,41 @@ static HRESULT Global_DateSerial(BuiltinDisp *This, VARIANT *args, unsigned args return hres; }
-static HRESULT Global_TimeSerial(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) +static HRESULT Global_TimeSerial(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res) { - FIXME("\n"); - return E_NOTIMPL; + int hour, minute, second; + UDATE ud = {{ 0 }}; + HRESULT hres; + double date; + + TRACE("\n"); + + assert(args_cnt == 3); + + if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL || V_VT(args + 2) == VT_NULL) + return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE); + + hres = to_int(args, &hour); + if (SUCCEEDED(hres)) + hres = to_int(args + 1, &minute); + if (SUCCEEDED(hres)) + hres = to_int(args + 2, &second); + + if (SUCCEEDED(hres)) + { + ud.st.wYear = 1899; + ud.st.wMonth = 12; + ud.st.wDay = 30; + ud.st.wHour = hour; + ud.st.wMinute = minute; + ud.st.wSecond = second; + hres = VarDateFromUdateEx(&ud, 0, 0, &date); + } + + if (SUCCEEDED(hres)) + hres = return_date(res, date); + + return hres; }
static HRESULT Global_InputBox(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index 758013c93ef..be1d4a806c0 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -2165,4 +2165,41 @@ sub testMonthNameError() end sub call testMonthNameError()
+sub testTimeSerial(hh, mm, ss, hhexp, mmexp, ssexp, dateexp) + dim x + x = TimeSerial(hh, mm, ss) + call ok(Hour(x) = hhexp, "hour = " & Hour(x) & " expected " & hhexp) + call ok(Minute(x) = mmexp, "minute = " & Minute(x) & " expected " & mmexp) + call ok(Second(x) = ssexp, "second = " & Second(x) & " expected " & ssexp) + call ok(Year(x) = Year(dateexp), "year = " & Year(x)) + call ok(Month(x) = Month(dateexp), "month = " & Month(x)) + call ok(Day(x) = Day(dateexp), "day = " & Day(x)) + call ok(getVT(x) = "VT_DATE*", "getVT = " & getVT(x)) +end sub + +sub testTimeSerialError() + on error resume next + dim x + call Err.clear() + x = TimeSerial(null, 1, 1) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + call TimeSerial(10, null, 1) + call ok(Err.number = 94, "Err.number = " & Err.number) + call Err.clear() + call TimeSerial(10, 1, null) + call ok(Err.number = 94, "Err.number = " & Err.number) +end sub + +call testTimeSerial(0, 0, 0, 0, 0, 0, DateSerial(1899, 12, 30)) +call testTimeSerial(10, 2, 1, 10, 2, 1, DateSerial(1899, 12, 30)) +call testTimeSerial(0, 2, 1, 0, 2, 1, DateSerial(1899, 12, 30)) +call testTimeSerial(24, 2, 1, 0, 2, 1, DateSerial(1899, 12, 31)) +call testTimeSerial(25, 2, 1, 1, 2, 1, DateSerial(1899, 12, 31)) +call testTimeSerial(50, 2, 1, 2, 2, 1, DateSerial(1900, 1, 1)) +call testTimeSerial(10, 60, 2, 11, 0, 2, DateSerial(1899, 12, 30)) +call testTimeSerial(10, 0, 60, 10, 1, 0, DateSerial(1899, 12, 30)) +call testTimeSerialError() + Call reportSuccess()
Signed-off-by: Jacek Caban jacek@codeweavers.com