oledb32: Implemented DataConvert DBTYPE_BSTR->DBTYPE_DBTIMESTAMP.

This commit is contained in:
Alistair Leslie-Hughes 2013-05-23 12:13:17 +10:00 committed by Alexandre Julliard
parent 0bf9266bc7
commit d103894ebc
2 changed files with 39 additions and 2 deletions

View File

@ -480,8 +480,34 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
DBTIMESTAMP *d=dst;
switch (src_type)
{
case DBTYPE_EMPTY: memset(d, 0, sizeof(DBTIMESTAMP)); hr = S_OK; break;
case DBTYPE_DBTIMESTAMP: memcpy(d, src, sizeof(DBTIMESTAMP)); hr = S_OK; break;
case DBTYPE_EMPTY: memset(d, 0, sizeof(DBTIMESTAMP)); hr = S_OK; break;
case DBTYPE_DBTIMESTAMP: memcpy(d, src, sizeof(DBTIMESTAMP)); 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;
d->hour = st.wHour;
d->minute = st.wMinute;
d->second = st.wSecond;
d->fraction = st.wMilliseconds * 1000000;
}
VariantClear(&var);
}
break;
case DBTYPE_DATE:
{
SYSTEMTIME st;

View File

@ -2666,12 +2666,14 @@ static void test_converttovar(void)
static void test_converttotimestamp(void)
{
static const WCHAR strW[] = {'2','0','1','3','-','0','5','-','1','4',' ','0','2',':','0','4',':','1','2',0};
DBTIMESTAMP ts = {2013, 5, 14, 2, 4, 12, 0};
DBTIMESTAMP dst;
DBSTATUS dst_status;
DBLENGTH dst_len;
VARIANT var;
HRESULT hr;
BSTR bstr;
VariantInit(&var);
V_VT(&var) = VT_DATE;
@ -2682,6 +2684,15 @@ static void test_converttotimestamp(void)
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == sizeof(dst), "got %ld\n", dst_len);
ok(!memcmp(&ts, &dst, sizeof(ts)), "Wrong timestamp\n");
bstr = SysAllocString(strW);
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(&ts, &dst, sizeof(ts)), "Wrong timestamp\n");
SysFreeString(bstr);
}
START_TEST(convert)