Commit 24e56bee authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

oledb32: Implement DataConvert DBTYPE_VARIANT(V_DATE)->DBTYPE_DBDATE.

parent 4bd39812
......@@ -421,6 +421,21 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
switch (src_type)
{
case DBTYPE_DBDATE: memcpy(d, src, sizeof(DBDATE)); hr = S_OK; break;
case DBTYPE_VARIANT:
if( V_VT((VARIANT*)src) == VT_DATE)
{
SYSTEMTIME st;
hr = (VariantTimeToSystemTime( V_DATE((VARIANT*)src), &st) ? S_OK : E_FAIL);
d->year = st.wYear;
d->month = st.wMonth;
d->day = st.wDay;
}
else
{
FIXME("Unimplemented variant type %d -> DBDATE\n", V_VT((VARIANT*)src));
return E_NOTIMPL;
}
break;
default: FIXME("Unimplemented conversion %04x -> DBDATE\n", src_type); return E_NOTIMPL;
}
break;
......@@ -446,7 +461,6 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
break;
}
case DBTYPE_VARIANT:
{
if( V_VT((VARIANT*)src) == VT_DATE)
{
SYSTEMTIME st;
......@@ -458,11 +472,13 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
d->minute = st.wMinute;
d->second = st.wSecond;
d->fraction = st.wMilliseconds * 1000000;
break;
}
else
{
FIXME("Unimplemented variant type %d -> DBTIMESTAMP\n", V_VT((VARIANT*)src));
}
return E_NOTIMPL;
}
break;
default: FIXME("Unimplemented conversion %04x -> DBTIMESTAMP\n", src_type); return E_NOTIMPL;
}
break;
......
......@@ -2462,6 +2462,7 @@ static void test_converttodbdate(void)
DBDATE ts = {2013, 5, 14};
DBDATE dst;
DBSTATUS dst_status;
VARIANT var;
dst_len = 0;
hr = IDataConvert_DataConvert(convert, DBTYPE_DBDATE, DBTYPE_DBDATE, sizeof(ts), &dst_len, &ts, &dst, 2, 0, &dst_status, 0, 0, 0);
......@@ -2470,6 +2471,15 @@ static void test_converttodbdate(void)
ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len);
ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
VariantInit(&var);
V_VT(&var) = VT_DATE;
V_DATE(&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");
}
......
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