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

oledb32: Support milliseconds when converting BSTR -> DBTIMESTAMP.

parent bf24c316
......@@ -566,6 +566,18 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
d->second = st.wSecond;
d->fraction = st.wMilliseconds * 1000000;
}
else
{
if(swscanf( s, L"%d-%d-%d %d:%d:%d.%d", &d->year, &d->month, &d->day, &d->hour, &d->minute,
&d->second, &d->fraction) != 7)
{
hr = DISP_E_TYPEMISMATCH;
*dst_status = DBSTATUS_E_CANTCONVERTVALUE;
*dst_len = get_length(dst_type);
}
else
hr = S_OK;
}
VariantClear(&var);
}
......
......@@ -3953,10 +3953,27 @@ static void test_converttotimestamp(void)
bstr = SysAllocString(strFullW);
dst_len = 0x1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
todo_wine ok(hr == S_OK, "got %08x\n", hr);
todo_wine ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
todo_wine ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
todo_wine ok(!memcmp(&ts1, &dst, sizeof(ts1)), "Wrong timestamp\n");
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(!memcmp(&ts1, &dst, sizeof(ts1)), "Wrong timestamp\n");
SysFreeString(bstr);
bstr = SysAllocString(L"2013-05-14 02:04:12.017000000");
dst_len = 0x1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 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(dst), "got %ld\n", dst_len);
ok(!memcmp(&ts1, &dst, sizeof(ts1)), "Wrong timestamp\n");
SysFreeString(bstr);
bstr = SysAllocString(L"2013/05/14 02:04:12.01700");
dst_len = 0x1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBTIMESTAMP, 0, &dst_len, &bstr, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
ok(hr == DISP_E_TYPEMISMATCH, "got %08x\n", hr);
ok(dst_status == DBSTATUS_E_CANTCONVERTVALUE, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
SysFreeString(bstr);
V_VT(&var) = VT_NULL;
......
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