mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix marshal round-tripping of fractional seconds (Time#subsec).
This commit is contained in:
parent
b6843f22ac
commit
96546bb63b
2 changed files with 8 additions and 0 deletions
|
@ -37,6 +37,7 @@ if Time.local(2010).zone != Marshal.load(Marshal.dump(Time.local(2010))).zone
|
|||
time.instance_eval do
|
||||
if zone = defined?(@_zone) && remove_instance_variable('@_zone')
|
||||
ary = to_a
|
||||
ary[0] += subsec if ary[0] == sec
|
||||
ary[-1] = zone
|
||||
utc? ? Time.utc(*ary) : Time.local(*ary)
|
||||
else
|
||||
|
|
|
@ -808,4 +808,11 @@ class TimeExtMarshalingTest < Test::Unit::TestCase
|
|||
assert_equal t.zone, unmarshaled.zone
|
||||
assert_equal t, unmarshaled
|
||||
end
|
||||
|
||||
def test_marshalling_preserves_fractional_seconds
|
||||
t = Time.parse('00:00:00.500')
|
||||
unmarshaled = Marshal.load(Marshal.dump(t))
|
||||
assert_equal t.to_f, unmarshaled.to_f
|
||||
assert_equal t, unmarshaled
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue