aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--test/ruby/test_time.rb7
-rw-r--r--time.c2
3 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b1f06eb0c3..f785a0d1c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Jan 22 21:05:34 2010 Tanaka Akira <akr@fsij.org>
+
+ * time.c (time_mload): add submicro into vtm.subsecx. [ruby-dev:40133]
+
Fri Jan 22 14:26:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (rdoc): needs encodings and exts.
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 39a8e297bb..d5dd86765f 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -191,6 +191,13 @@ class TestTime < Test::Unit::TestCase
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))))
diff --git a/time.c b/time.c
index 2d5edbe338..6b0685d591 100644
--- a/time.c
+++ b/time.c
@@ -3780,6 +3780,7 @@ time_mload(VALUE time, VALUE str)
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 @@ time_mload(VALUE time, VALUE str)
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);