Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/oledb32/convert.c | 39 +++++++++++++++++++++++++++++++++++++++ dlls/oledb32/tests/convert.c | 8 ++++---- 2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index f18c756..9b909fd 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -527,6 +527,45 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, d->second = st.wSecond; d->fraction = st.wMilliseconds * 1000000; } + else + { + WCHAR *de = s; + DWORD len = SysStringLen(s); + + TRACE("String with Milliseconds: %s\n", debugstr_w(s)); + + VariantClear(&var); + + while (len && de[len] != '.') + { + len--; + } + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocStringLen(s, len); + 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 = 0; + + VariantClear(&var); + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(de + (len+1)); + if(VariantChangeType(&var, &var, 0, VT_I4) == S_OK) + { + TRACE("Millseconds: %d\n", V_I4(&var)); + d->fraction = V_I4(&var); + } + } + }
VariantClear(&var); } diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c index 5dab9ff..4a5c05e 100644 --- a/dlls/oledb32/tests/convert.c +++ b/dlls/oledb32/tests/convert.c @@ -3641,10 +3641,10 @@ 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);
V_VT(&var) = VT_NULL;
On 1/8/19 6:17 AM, Alistair Leslie-Hughes wrote:
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com
dlls/oledb32/convert.c | 39 +++++++++++++++++++++++++++++++++++++++ dlls/oledb32/tests/convert.c | 8 ++++---- 2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index f18c756..9b909fd 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -527,6 +527,45 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, d->second = st.wSecond; d->fraction = st.wMilliseconds * 1000000; }
else
{
WCHAR *de = s;
DWORD len = SysStringLen(s);
TRACE("String with Milliseconds: %s\n", debugstr_w(s));
VariantClear(&var);
while (len && de[len] != '.')
{
len--;
}
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocStringLen(s, len);
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 = 0;
VariantClear(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(de + (len+1));
if(VariantChangeType(&var, &var, 0, VT_I4) == S_OK)
{
TRACE("Millseconds: %d\n", V_I4(&var));
d->fraction = V_I4(&var);
}
}
}
I think this could reuse existing VariantChangeType() block. Also, is it always dot-separated? Could it depend on locale/settings? Shouldn't it be handled by some Variant* function instead?
VariantClear(&var); }
diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c index 5dab9ff..4a5c05e 100644 --- a/dlls/oledb32/tests/convert.c +++ b/dlls/oledb32/tests/convert.c @@ -3641,10 +3641,10 @@ 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);
V_VT(&var) = VT_NULL;
Hi Nikolay,
On 8/1/19 5:38 pm, Nikolay Sivov wrote:
On 1/8/19 6:17 AM, Alistair Leslie-Hughes wrote:
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com
+ }
I think this could reuse existing VariantChangeType() block. Also, is it always dot-separated? Could it depend on locale/settings? Shouldn't it be handled by some Variant* function instead?
Sure, I'll take a look reusing an existing Variant Function if possible for the Date convert.
There isn't a Variant* function that deals with milliseconds on windows. I added a test for this scenario
(884c6ddd516478a94cd4e42ff5510ad226e69bde). It seems to be a oledb32 only type conversion.
To my knowledge it's always dot-separated however its seems to be database dependent if the milliseconds is included.
For example, Postgres doesn't whereas MSSQL/Firefird do.
Regards
Alistair.