Commit aa71e545 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

oleaut32: Take lcid into account while parsing input variant in VARIANT_FormatDate.

parent a6259d31
......@@ -564,6 +564,10 @@ static void test_VarFormatFromTokens(void)
static const WCHAR number[] = {'6',',','9','0',0};
static const WCHAR number_us[] = {'6','9','0','.','0','0',0};
static WCHAR date_fmt[] = {'d','d','-','m','m',0};
static const WCHAR date[] = {'1','2','-','1','1',0};
static const WCHAR date_us[] = {'1','1','-','1','2',0};
BYTE buff[256];
LCID lcid;
VARIANT var;
......@@ -590,6 +594,27 @@ static void test_VarFormatFromTokens(void)
SysFreeString(bstr);
VariantClear(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(date);
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
hres = VarTokenizeFormatString(date_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
hres = VarFormatFromTokens(&var, date_fmt, buff, 0, &bstr, lcid);
ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
ok(!strcmpW(bstr, date_us), "incorrectly formatted date: %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
lcid = MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT);
hres = VarTokenizeFormatString(date_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
hres = VarFormatFromTokens(&var, date_fmt, buff, 0, &bstr, lcid);
ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
ok(!strcmpW(bstr, date), "incorrectly formatted date: %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
VariantClear(&var);
}
START_TEST(varformat)
......
......@@ -1621,7 +1621,7 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
{
USHORT usFlags = dwFlags & VARIANT_CALENDAR_HIJRI ? VAR_CALENDAR_HIJRI : 0;
hRes = VariantChangeTypeEx(&vDate, pVarIn, LCID_US, usFlags, VT_DATE);
hRes = VariantChangeTypeEx(&vDate, pVarIn, lcid, usFlags, VT_DATE);
if (FAILED(hRes))
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