Commit 9af3a79b authored by David Kahurani's avatar David Kahurani Committed by Alexandre Julliard

oleaut32: Handle DATE in string form in VarFormat.

Testing has proven that coercion functions should reject the value which indicates that this is handled as a special case in VarFormat Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=13778Signed-off-by: 's avatarDavid Kahurani <k.kahurani@gmail.com>
parent 97a38020
......@@ -304,8 +304,8 @@ static void test_VarFormat(void)
VARFMT(VT_BSTR,V_BSTR,bstrin,"<&>&",S_OK,"testing");
SysFreeString(bstrin);
bstrin = SysAllocString(L"39697.11");
todo_wine VARFMT(VT_BSTR,V_BSTR,bstrin,"hh:mm",S_OK,"02:38");
todo_wine VARFMT(VT_BSTR,V_BSTR,bstrin,"mm-dd-yy",S_OK,"09-06-08");
VARFMT(VT_BSTR,V_BSTR,bstrin,"hh:mm",S_OK,"02:38");
VARFMT(VT_BSTR,V_BSTR,bstrin,"mm-dd-yy",S_OK,"09-06-08");
SysFreeString(bstrin);
/* Numeric values are converted to strings then output */
VARFMT(VT_I1,V_I1,1,"<&>&",S_OK,"1");
......
......@@ -1585,8 +1585,34 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
USHORT usFlags = dwFlags & VARIANT_CALENDAR_HIJRI ? VAR_CALENDAR_HIJRI : 0;
hRes = VariantChangeTypeEx(&vDate, pVarIn, lcid, usFlags, VT_DATE);
/* 31809.40 and similar are treated as invalid by coercion functions but
* it simply is a DATE in string form as far as VarFormat is concerned
*/
if (FAILED(hRes))
return hRes;
{
if (V_TYPE(pVarIn) == VT_BSTR)
{
DATE out;
OLECHAR *endptr = NULL;
/* Try consume the string with wcstod */
double tmp = wcstod(V_BSTR(pVarIn), &endptr);
/* Not a double in string form */
if (*endptr)
return hRes;
hRes = VarDateFromR8(tmp, &out);
if (FAILED(hRes))
return hRes;
V_VT(&vDate) = VT_DATE;
V_DATE(&vDate) = out;
}
else
return hRes;
}
dateHeader = (FMT_DATE_HEADER*)(rgbTok + FmtGetPositive(header));
}
......
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