From c5487618f56cca6211699046795728f99f91a555 Mon Sep 17 00:00:00 2001 From: suke Date: Mon, 1 Sep 2014 11:16:57 +0000 Subject: * ext/win32ole/win32ole.c (rbtime2vtdate): try to convert millisecond of Time object to millisecond of VT_DATE VARIANT. * test/win32ole/test_win32ole_variant.rb (test_conversion_time2date_with_msec): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/win32ole/test_win32ole_variant.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb index 216449f102..a4edc0891c 100644 --- a/test/win32ole/test_win32ole_variant.rb +++ b/test/win32ole/test_win32ole_variant.rb @@ -396,6 +396,19 @@ if defined?(WIN32OLE_VARIANT) assert_equal(789, (t.nsec / 1000000).round) end + def test_conversion_time2date_with_msec + t0 = Time.new(2014, 8, 27, 12, 34, 56) + t0 += 0.789 + t1 = WIN32OLE_VARIANT.new(t0).value + assert_equal("2014-08-27 12:34:56", t1.strftime('%Y-%m-%d %H:%M:%S')) + assert_equal(789, (t1.nsec / 1000000).round) + + t0 = Time.now + t1 = WIN32OLE_VARIANT.new(t0).value + assert_equal(t0.strftime('%Y-%m-%d %H:%M:%S'), t1.strftime('%Y-%m-%d %H:%M:%S')) + assert_equal(t0.nsec.round(-6), t1.nsec.round(-6)) + end + # this test failed because of VariantTimeToSystemTime # and SystemTimeToVariantTime API ignores wMilliseconds # member of SYSTEMTIME struct. -- cgit v1.2.3