Skip to content

Instantly share code, notes, and snippets.

@yaauie
Created November 21, 2013 07:11
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 yaauie/7577249 to your computer and use it in GitHub Desktop.
Save yaauie/7577249 to your computer and use it in GitHub Desktop.

It looks like Ruby's Time::strptime isn't properly plumbed to strptime(3) and ignores week arguments altogether.

001> RUBY_DESCRIPTION
# => "ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]"
002> require 'time'
# => true
003> fmt_string = '%Y-W%W-%w'
# => "%Y-W%W-%w"
004> week_iso8601 = Time.now.strftime(fmt_string) # formatting works
# => "2013-W46-4"
005> Time.strptime(week_iso8601, fmt_string) # but parsing doesn't.
# => 2013-01-01 00:00:00 +0000

So far I can repro this in 1.9.3 and jruby-1.7.4 on my local machine, but I would appreciate a repro on a non-mac box before I dive in too deep.

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