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.


Josh Bourgeois

I’m not a core developer, but I have noticed that you are comparing how ActiveRecord handles parsing a timestamp with Date.parse.
Try comparing with Time.zone.parse:


=> Sat, 02 Feb 0002 00:00:00 LMT -07:52

Assuming you are referring to the missing century, it is a known issue/feature/problem.



It doesn’t look like it is planned to be changed.