Commit 4ee4d4e2 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

oledb32: Coerce Variant to VT_DATE when converting data.

parent 65e42ac0
......@@ -475,10 +475,13 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
}
break;
case DBTYPE_VARIANT:
if( V_VT((VARIANT*)src) == VT_DATE)
{
VariantInit(&tmp);
if ((hr = VariantChangeType(&tmp, (VARIANT*)src, 0, VT_DATE)) == S_OK)
{
SYSTEMTIME st;
hr = (VariantTimeToSystemTime( V_DATE((VARIANT*)src), &st) ? S_OK : E_FAIL);
hr = (VariantTimeToSystemTime( V_DATE(&tmp), &st) ? S_OK : E_FAIL);
d->year = st.wYear;
d->month = st.wMonth;
d->day = st.wDay;
......@@ -489,6 +492,7 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
return E_NOTIMPL;
}
break;
}
default: FIXME("Unimplemented conversion %04x -> DBDATE\n", src_type); return E_NOTIMPL;
}
break;
......
......@@ -3357,6 +3357,25 @@ static void test_converttodbdate(void)
ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
V_VT(&var) = VT_R8;
V_R8(&var) = 41408.086250;
dst_len = 0;
hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(strW);
dst_len = 0;
hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
VariantClear(&var);
dst_len = 0;
bstr = SysAllocString(strW);
hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBDATE, 0, &dst_len, &bstr, &dst, 2, 0, &dst_status, 0, 0, 0);
......
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