travisjeffery / timecop

A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.
MIT License
3.36k stars 223 forks source link

%W is not handled properly #380

Closed joshuacronemeyer closed 1 year ago

joshuacronemeyer commented 2 years ago

We see this:

irb(main):001:0> week = '201810'
=> "201810"
irb(main):002:0> Date.strptime(week, "%Y%W")
=> Mon, 05 Mar 2018
irb(main):003:0> require 'timecop'
=> true
irb(main):004:0> Date.strptime(week, "%Y%W")
=> Mon, 01 Jan 2018

Originally posted by @lisbethmarianne in https://github.com/travisjeffery/timecop/issues/132#issuecomment-429345309

joshuacronemeyer commented 2 years ago

I was closing #132 because the behavior referenced in the issue has changed and seems like not a bug anymore, but this comment was highlighting something that doesn't work. we don't handle the :week symbol that this date format causes in _strptime.