Skip to content

Instantly share code, notes, and snippets.

@wraithgar
Created December 5, 2019 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wraithgar/82b7dcbcef29ac695b6e8b6259258c1c to your computer and use it in GitHub Desktop.
Save wraithgar/82b7dcbcef29ac695b6e8b6259258c1c to your computer and use it in GitHub Desktop.
ruby strftime/strptime bug
require 'date'
Date.strptime(Date.new(2006,1,1).strftime('%U-%Y'), '%U-%Y')
#<Date: 2006-01-01 ((2453737j,0s,0n),+0s,2299161j)>
Date.strptime(Date.new(2000,12,31).strftime('%U-%Y'), '%U-%Y')
#<Date: 2000-12-31 ((2451910j,0s,0n),+0s,2299161j)>
Date.strptime(Date.new(2001,1,7).strftime('%U-%Y'), '%U-%Y')
#<Date: 2001-01-07 ((2451917j,0s,0n),+0s,2299161j)>
Date.strptime(Date.new(2001,1,1).strftime('%U-%Y'), '%U-%Y')
# Traceback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment