{"action":"opened","pull_request":{"created_at":"2011-11-19T06:17:21Z","state":"open","review_comments":0,"patch_url":"https://github.com/flori/json/pull/104.patch","changed_files":2,"updated_at":"2011-11-19T06:17:21Z","_links":{"review_comments":{"href":"https://api.github.com/repos/flori/json/pulls/104/comments"},"comments":{"href":"https://api.github.com/repos/flori/json/issues/104/comments"},"html":{"href":"https://github.com/flori/json/pull/104"},"self":{"href":"https://api.github.com/repos/flori/json/pulls/104"}},"comments":0,"user":{"gravatar_id":"e9ebfedba32a338542b3adb482cf0e0f","id":183241,"url":"https://api.github.com/users/jpartlow","login":"jpartlow","avatar_url":"https://secure.gravatar.com/avatar/e9ebfedba32a338542b3adb482cf0e0f?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"issue_url":"https://github.com/flori/json/issues/104","deletions":3,"body":"Hi,\r\n\r\nWorking with the JSON 1.6.1 lib in Ruby 1.9.2 (MRI), I'm finding that Time instances don't round trip properly, so:\r\n\r\n```\r\njpartlow@halbarad:~/dev/json$ irb -I lib\r\nruby-1.9.2-p290 :001 > require 'json'\r\n => true \r\nruby-1.9.2-p290 :002 > require 'json/add/time'\r\n => true \r\nruby-1.9.2-p290 :003 > t = Time.now\r\n => 2011-11-18 22:01:37 -0800 \r\nruby-1.9.2-p290 :004 > t2 = JSON(JSON(t))\r\n => 2011-11-18 22:15:46 -0800 \r\nruby-1.9.2-p290 :005 > t == t2\r\n => false \r\nruby-1.9.2-p290 :006 > t.nsec\r\n => 513434780 \r\nruby-1.9.2-p290 :007 > t2.nsec\r\n => 513434000 \r\nruby-1.9.2-p290 :005 > Marshal.load(Marshal.dump(t)) == t\r\n => true \r\n```\r\n\r\nIt looks like Time.json_create has two issues, one it was checking for the existence of #tv_sec in Time rather than a Time instance, and so was never running the variant meant for the newer Time class with nsec attribute.  Also, I think the newer Time.at requires (sec, usec) where usec can be fractional to represent nanosecs.\r\n\r\nThe test suite was masking this by checking t.inspect rather than t for the equality test.\r\n\r\nI've only tested this on 1.9.2, so I might be overlooking something that is important for another Ruby version.\r\n\r\nthanks,\r\nJosh\r\n\r\n  ruby:\r\n    interpreter:  \"ruby\"\r\n    version:      \"1.9.2p290\"\r\n    date:         \"2011-07-09\"\r\n    platform:     \"x86_64-linux\"\r\n    patchlevel:   \"2011-07-09 revision 32553\"\r\n    full_version: \"ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]\"","merged":false,"commits":1,"mergeable":null,"additions":3,"id":511107,"base":{"user":{"gravatar_id":"1442d84cb806bf6e49709e75ae58ce63","id":15918,"url":"https://api.github.com/users/flori","login":"flori","avatar_url":"https://secure.gravatar.com/avatar/1442d84cb806bf6e49709e75ae58ce63?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"repo":{"created_at":"2009-08-24T22:21:39Z","pushed_at":"2011-11-09T22:11:01Z","private":false,"updated_at":"2011-11-18T22:45:12Z","clone_url":"https://github.com/flori/json.git","name":"json","watchers":185,"master_branch":"master","svn_url":"https://svn.github.com/flori/json","language":"Ruby","forks":39,"owner":{"gravatar_id":"1442d84cb806bf6e49709e75ae58ce63","id":15918,"url":"https://api.github.com/users/flori","login":"flori","avatar_url":"https://secure.gravatar.com/avatar/1442d84cb806bf6e49709e75ae58ce63?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":287024,"homepage":"http://flori.github.com/json","description":"JSON implementation for Ruby","git_url":"git://github.com/flori/json.git","html_url":"https://github.com/flori/json","url":"https://api.github.com/repos/flori/json","size":300,"fork":false,"ssh_url":"git@github.com:flori/json.git","open_issues":20},"sha":"4ee26ac90981bbe5d7b5114ddd5036a5cea24251","ref":"master","label":"flori:master"},"number":104,"merged_by":null,"head":{"user":{"gravatar_id":"e9ebfedba32a338542b3adb482cf0e0f","id":183241,"url":"https://api.github.com/users/jpartlow","login":"jpartlow","avatar_url":"https://secure.gravatar.com/avatar/e9ebfedba32a338542b3adb482cf0e0f?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"repo":{"created_at":"2011-11-18T22:45:12Z","pushed_at":"2011-11-19T05:43:23Z","private":false,"updated_at":"2011-11-19T05:43:26Z","clone_url":"https://github.com/jpartlow/json.git","name":"json","watchers":1,"master_branch":"master","svn_url":"https://svn.github.com/jpartlow/json","language":"Ruby","forks":0,"owner":{"gravatar_id":"e9ebfedba32a338542b3adb482cf0e0f","id":183241,"url":"https://api.github.com/users/jpartlow","login":"jpartlow","avatar_url":"https://secure.gravatar.com/avatar/e9ebfedba32a338542b3adb482cf0e0f?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":2806149,"homepage":"http://flori.github.com/json","description":"JSON implementation for Ruby","git_url":"git://github.com/jpartlow/json.git","html_url":"https://github.com/jpartlow/json","url":"https://api.github.com/repos/jpartlow/json","size":124,"fork":true,"ssh_url":"git@github.com:jpartlow/json.git","open_issues":0},"sha":"a04856d8ea1bc5e98e9a8ef299dffd6bee365fc1","ref":"master","label":"jpartlow:master"},"title":"Fix for Time.json_create in Ruby 1.9.2","closed_at":null,"html_url":"https://github.com/flori/json/pull/104","url":"https://api.github.com/repos/flori/json/pulls/104","diff_url":"https://github.com/flori/json/pull/104.diff","merged_at":null},"number":104}