diff --git a/ChangeLog b/ChangeLog index a693b4e657..88b6f34d60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Jul 4 23:12:53 2008 Masaki Suketa + + * ext/win32ole/win32ole.c (d2time): fix the bug of VT_DATE + to String conversion when negative value. + + * test/win32ole/test_win32ole_variant.rb: ditto. + Fri Jul 4 22:15:29 2008 Tanaka Akira * lib/test/unit/testcase.rb: collect decendants of diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index ea027c153a..a972c8bc68 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef HAVE_STDARG_PROTOTYPES #include #define va_init_list(a,b) va_start(a,b) @@ -117,7 +118,7 @@ #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "1.1.8" +#define WIN32OLE_VERSION "1.1.9" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -763,7 +764,7 @@ d2time(double v, int *hh, int *mm, int *ss) double d_hh, d_mm, d_ss; int i_hh, i_mm, i_ss; - double d = v * 86400.0; + double d = fabs(v * 86400.0); d_hh = d / 3600.0; i_hh = (int)d_hh; diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb index ddce062820..1226e0de50 100644 --- a/test/win32ole/test_win32ole_variant.rb +++ b/test/win32ole/test_win32ole_variant.rb @@ -540,6 +540,44 @@ if defined?(WIN32OLE_VARIANT) } end + def test_conversion_vt_date + obj = WIN32OLE_VARIANT.new(-657434, WIN32OLE::VARIANT::VT_DATE) + assert_equal("0100/01/01 00:00:00", obj.value) + + obj = WIN32OLE_VARIANT.new("1500/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE) + assert_equal("1500/12/29 23:59:59", obj.value) + + obj = WIN32OLE_VARIANT.new("1500/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE) + assert_equal("1500/12/30 00:00:00", obj.value) + + obj = WIN32OLE_VARIANT.new("1500/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE) + assert_equal("1500/12/30 00:00:01", obj.value) + + obj = WIN32OLE_VARIANT.new("1899/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE) + assert_equal("1899/12/29 23:59:59", obj.value) + + obj = WIN32OLE_VARIANT.new("1899/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE) + assert_equal("1899/12/30 00:00:00", obj.value) + + obj = WIN32OLE_VARIANT.new("1899/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE) + assert_equal("1899/12/30 00:00:01", obj.value) + + obj = WIN32OLE_VARIANT.new(0, WIN32OLE::VARIANT::VT_DATE) + assert_equal("1899/12/30 00:00:00", obj.value) + + obj = WIN32OLE_VARIANT.new("2008/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE) + assert_equal("2008/12/29 23:59:59", obj.value) + + obj = WIN32OLE_VARIANT.new("2008/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE) + assert_equal("2008/12/30 00:00:00", obj.value) + + obj = WIN32OLE_VARIANT.new("2008/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE) + assert_equal("2008/12/30 00:00:01", obj.value) + + obj = WIN32OLE_VARIANT.new("9999/12/31 23:59:59", WIN32OLE::VARIANT::VT_DATE) + assert_equal("9999/12/31 23:59:59", obj.value) + end + def test_create_nil_dispatch var = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DISPATCH) assert_nil(var.value)