Commit 0d6eadc4 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

oledb32: Implement DataConvert DBTYPE_VARIANT->DBTYPE_DATE.

parent 8e2cd615
......@@ -428,6 +428,27 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
switch (src_type)
{
case DBTYPE_DBDATE: memcpy(d, src, sizeof(DBDATE)); hr = S_OK; break;
case DBTYPE_BSTR:
{
VARIANT var;
BSTR s = *(WCHAR**)src;
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(s);
if ((hr = VariantChangeType(&var, &var, 0, VT_DATE)) == S_OK)
{
SYSTEMTIME st;
hr = (VariantTimeToSystemTime( V_DATE(&var), &st) ? S_OK : E_FAIL);
d->year = st.wYear;
d->month = st.wMonth;
d->day = st.wDay;
}
VariantClear(&var);
}
break;
case DBTYPE_VARIANT:
if( V_VT((VARIANT*)src) == VT_DATE)
{
......
......@@ -2467,10 +2467,12 @@ static void test_converttodbdate(void)
{
DBLENGTH dst_len;
HRESULT hr;
static WCHAR strW[] = {'2','0','1','3','-','0','5','-','1','4',0};
DBDATE ts = {2013, 5, 14};
DBDATE dst;
DBSTATUS dst_status;
VARIANT var;
BSTR bstr;
dst_len = 0;
hr = IDataConvert_DataConvert(convert, DBTYPE_DBDATE, DBTYPE_DBDATE, sizeof(ts), &dst_len, &ts, &dst, 2, 0, &dst_status, 0, 0, 0);
......@@ -2488,6 +2490,15 @@ static void test_converttodbdate(void)
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");
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);
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");
SysFreeString(bstr);
}
......
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