I'm porting an old rails app to Rails 4 and got stumped tonight on time conversions.
This worked: Loading development environment (Rails 2.3.18) > > Time.now.to_s => "08/14/2013 07:09PM" > > Time.now.to_s.to_time => Wed Aug 14 19:09:00 UTC 2013 Now it doesn't on Rails 4.0: Loading development environment (Rails 4.0.0) irb(main):001:0> Time.now => 2013-08-15 00:19:48 -0500 irb(main):002:0> Time.now.to_s => "08/15/2013 12:19AM" irb(main):003:0> Time.now.to_s.to_time ArgumentError: argument out of range from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/core_ext/string/conversions.rb:23:in `initialize' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/core_ext/string/conversions.rb:23:in `new' If I remove this from my initializer: Time::DATE_FORMATS.merge!(:default => '%m/%d/%Y %I:%M%p') It works again in 4.0, but the output format is wrong. I don't want my users reading that time format: Loading development environment (Rails 4.0.0) irb(main):001:0> Time.now.to_s => "2013-08-15 00:32:07 -0500" irb(main):002:0> Time.now.to_s.to_time => 2013-08-15 00:32:15 -0500 If it were a simple single string I was parsing, I could do a custom one off parse and be done with it, but this is site wide. Passing entire hashes to models is causing this error to manifest its self. Any ideas to get Rails 4.0 to not just produce a custom Time string but parse the same way as well? Seems like it should be simple, but perhaps it's just getting late here. ;') Thanks! Phil -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/476db361-8fea-4b10-aa4e-0d70879eeaa7%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.