Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord's to_json method ignores timezone when serializing Time objects

#4958

Simple example to demonstrate (tested in Rails 2.3.5):

now = Time.parse("Thu Jun 24 15:41:23 UTC 2010")
now2 = Time.parse(now.to_json)

check these results out:
puts now => Thu Jun 24 15:41:23 UTC 2010
puts now2 => Thu Jun 24 11:41:23 -0400 2010

They're different!

This is because:
now.to_json => ""2010/06/24 15:41:23 +0000"" as you can see, the timezone is incorrectly specified

Reported by rathboma · June 24th, 2010 @ 04:45 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to invalid
    • Importance changed from to Low

    This is working ok on both 2-3-stable and master branches.
    Please try again on with the latest git code and if you still get the error i will reopen the issue.
    Thank you

    June 26th, 2010 @ 10:29 PM