Skip to content

Instantly share code, notes, and snippets.

@rudle
Created March 25, 2013 00:19
Show Gist options
  • Save rudle/5234198 to your computer and use it in GitHub Desktop.
Save rudle/5234198 to your computer and use it in GitHub Desktop.
Date.strftime, Date.strptime don't commute
Date.today.strftime('%-m%-d%y') # 3242013
Date.strptime('3242013','%-m%-d%y') # ArgumentError: invalid date
@tamird
Copy link

tamird commented Mar 25, 2013

bug report it. should be a capital Y, though:

2.0.0p0 :001 > require 'date'
 => true
2.0.0p0 :002 > f = '%-m%-d%Y'; t = Date.today.strftime(f); p t; Date.strptime(t, f)
"3242013"
ArgumentError: invalid date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment