Alistair Leslie-Hughes : oledb32: Support milliseconds when converting BSTR -> DBTIMESTAMP.

Alexandre Julliard julliard at winehq.org
Mon Oct 21 15:28:37 CDT 2019


Module: wine
Branch: master
Commit: f437d15100997c37d1dfa1fae66744b44f081d1e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f437d15100997c37d1dfa1fae66744b44f081d1e

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Mon Oct 21 00:23:54 2019 +0000

oledb32: Support milliseconds when converting BSTR -> DBTIMESTAMP.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/oledb32/convert.c       | 12 ++++++++++++
 dlls/oledb32/tests/convert.c | 25 +++++++++++++++++++++----
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
index a5bbdbc245..2fc65c7403 100644
--- a/dlls/oledb32/convert.c
+++ b/dlls/oledb32/convert.c
@@ -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);
         }
diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c
index 51fd2f7fa3..28401e68c9 100644
--- a/dlls/oledb32/tests/convert.c
+++ b/dlls/oledb32/tests/convert.c
@@ -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;




More information about the wine-cvs mailing list