jbourgeois@pivotal.io
2014-Aug-11 17:14 UTC
Odd behavior around ActiveRecord date parsing?
Hi Rails Core,
I was wondering how ActiveRecord is parsing dates, as it seems
counterintuitive to how Ruby does it.
RUBYCONSOLE:> Date.parse("2/2/2")
=> *Sat, 02 Feb 2002*
$ rails g model receipt occurred_at:date
RUBYCONSOLE:> Receipt.create!(occurred_at: "2/2/2")
=> #<Receipt id: 1, occurred_at: "*0002-02-02*", created_at:
"2014-08-11
17:06:18", updated_at: "2014-08-11 17:06:18">
RUBYCONSOLE:> Date.parse("0002-02-02")
=> Thu, 02 Feb 0002
What's up here? I'd like my receipt to be on printer paper, not stone
tablets.
Thanks!
Josh Bourgeois
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.