[前][次][番号順一覧][スレッド一覧]

ruby-changes:14540

From: akr <ko1@a...>
Date: Fri, 22 Jan 2010 21:08:18 +0900 (JST)
Subject: [ruby-changes:14540] Ruby:r26377 (trunk): * time.c (time_mload): add submicro into vtm.subsecx.

akr	2010-01-22 21:08:02 +0900 (Fri, 22 Jan 2010)

  New Revision: 26377

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26377

  Log:
    * time.c (time_mload): add submicro into vtm.subsecx.  [ruby-dev:40133]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_time.rb
    trunk/time.c

Index: time.c
===================================================================
--- time.c	(revision 26376)
+++ time.c	(revision 26377)
@@ -3780,6 +3780,7 @@
             int digit;
             ptr = (unsigned char*)StringValuePtr(submicro);
             len = RSTRING_LEN(submicro);
+            nsec = 0;
             if (0 < len) {
                 if (10 <= (digit = ptr[0] >> 4)) goto end_submicro;
                 nsec += digit * 100;
@@ -3790,6 +3791,7 @@
                 if (10 <= (digit = ptr[1] >> 4)) goto end_submicro;
                 nsec += digit;
             }
+            vtm.subsecx = add(vtm.subsecx, mulquo(LONG2FIX(nsec), INT2FIX(TIME_SCALE), LONG2FIX(1000000000)));
 end_submicro: ;
         }
         timexv = timegmxv(&vtm);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26376)
+++ ChangeLog	(revision 26377)
@@ -1,3 +1,7 @@
+Fri Jan 22 21:05:34 2010  Tanaka Akira  <akr@f...>
+
+	* time.c (time_mload): add submicro into vtm.subsecx.  [ruby-dev:40133] 
+
 Fri Jan 22 14:26:36 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (rdoc): needs encodings and exts.
Index: test/ruby/test_time.rb
===================================================================
--- test/ruby/test_time.rb	(revision 26376)
+++ test/ruby/test_time.rb	(revision 26377)
@@ -191,6 +191,13 @@
     assert_marshal_roundtrip(Time.at(0, 0.120))
   end
 
+  def test_marshal_nsec_191
+    # generated by ruby 1.9.1p376
+    m = "\x04\bIu:\tTime\r \x80\x11\x80@\xE2\x01\x00\x06:\rsubmicro\"\ax\x90"
+    t = Marshal.load(m)
+    assert_equal(Time.at(Rational(123456789, 1000000000)), t, "[ruby-dev:40133]")
+  end
+
   def test_marshal_rational
     assert_marshal_roundtrip(Time.at(0, Rational(1,3)))
     assert_not_match(/Rational/, Marshal.dump(Time.at(0, Rational(1,3))))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]