diff options
author | Florian Frank <flori@ping.de> | 2011-11-22 10:23:04 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2011-11-22 10:23:04 +0100 |
commit | 504e6d464d7eb3b153f5e107698588f135de8511 (patch) | |
tree | 9b7c4852b62c1131a9582f6667ca5454b45e75a9 | |
parent | 8828e9cd225ac0591b3a5015a53cb91b7232bd83 (diff) | |
parent | a04856d8ea1bc5e98e9a8ef299dffd6bee365fc1 (diff) | |
download | json-504e6d464d7eb3b153f5e107698588f135de8511.tar.gz |
Merge branch 'master' of https://github.com/jpartlow/json into jpartlow-master
-rw-r--r-- | lib/json/add/time.rb | 4 | ||||
-rwxr-xr-x | tests/test_json_addition.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/json/add/time.rb b/lib/json/add/time.rb index abc807a..9755707 100644 --- a/lib/json/add/time.rb +++ b/lib/json/add/time.rb @@ -10,8 +10,8 @@ class Time if usec = object.delete('u') # used to be tv_usec -> tv_nsec object['n'] = usec * 1000 end - if respond_to?(:tv_nsec) - at(*object.values_at('s', 'n')) + if instance_methods.include?(:tv_nsec) + at(object['s'], Rational(object['n'], 1000)) else at(object['s'], object['n'] / 1000) end diff --git a/tests/test_json_addition.rb b/tests/test_json_addition.rb index 1b85e02..e262e25 100755 --- a/tests/test_json_addition.rb +++ b/tests/test_json_addition.rb @@ -130,7 +130,7 @@ class TC_JSONAddition < Test::Unit::TestCase def test_core t = Time.now - assert_equal t.inspect, JSON(JSON(t)).inspect + assert_equal t, JSON(JSON(t)) d = Date.today assert_equal d, JSON(JSON(d)) d = DateTime.civil(2007, 6, 14, 14, 57, 10, Rational(1, 12), 2299161) |