mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* time.c (time_mload): add submicro into vtm.subsecx. [ruby-dev:40133]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0f02abb31b
commit
1d674dc547
3 changed files with 13 additions and 0 deletions
|
@ -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>
|
Fri Jan 22 14:26:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* common.mk (rdoc): needs encodings and exts.
|
* common.mk (rdoc): needs encodings and exts.
|
||||||
|
|
|
@ -191,6 +191,13 @@ class TestTime < Test::Unit::TestCase
|
||||||
assert_marshal_roundtrip(Time.at(0, 0.120))
|
assert_marshal_roundtrip(Time.at(0, 0.120))
|
||||||
end
|
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
|
def test_marshal_rational
|
||||||
assert_marshal_roundtrip(Time.at(0, Rational(1,3)))
|
assert_marshal_roundtrip(Time.at(0, Rational(1,3)))
|
||||||
assert_not_match(/Rational/, Marshal.dump(Time.at(0, Rational(1,3))))
|
assert_not_match(/Rational/, Marshal.dump(Time.at(0, Rational(1,3))))
|
||||||
|
|
2
time.c
2
time.c
|
@ -3780,6 +3780,7 @@ time_mload(VALUE time, VALUE str)
|
||||||
int digit;
|
int digit;
|
||||||
ptr = (unsigned char*)StringValuePtr(submicro);
|
ptr = (unsigned char*)StringValuePtr(submicro);
|
||||||
len = RSTRING_LEN(submicro);
|
len = RSTRING_LEN(submicro);
|
||||||
|
nsec = 0;
|
||||||
if (0 < len) {
|
if (0 < len) {
|
||||||
if (10 <= (digit = ptr[0] >> 4)) goto end_submicro;
|
if (10 <= (digit = ptr[0] >> 4)) goto end_submicro;
|
||||||
nsec += digit * 100;
|
nsec += digit * 100;
|
||||||
|
@ -3790,6 +3791,7 @@ time_mload(VALUE time, VALUE str)
|
||||||
if (10 <= (digit = ptr[1] >> 4)) goto end_submicro;
|
if (10 <= (digit = ptr[1] >> 4)) goto end_submicro;
|
||||||
nsec += digit;
|
nsec += digit;
|
||||||
}
|
}
|
||||||
|
vtm.subsecx = add(vtm.subsecx, mulquo(LONG2FIX(nsec), INT2FIX(TIME_SCALE), LONG2FIX(1000000000)));
|
||||||
end_submicro: ;
|
end_submicro: ;
|
||||||
}
|
}
|
||||||
timexv = timegmxv(&vtm);
|
timexv = timegmxv(&vtm);
|
||||||
|
|
Loading…
Reference in a new issue