-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strptime
incorrectly parses the date
#132
Comments
Very odd, I'm getting odd but different results here: Date.strptime("11-01-08", '%Y-%m-%d').strftime
# => "0011-01-08"
require 'timecop'
# => true
Date.strptime("11-01-08", '%Y-%m-%d').strftime
# => "0011-01-10"
Date.strptime("11-01-08", '%Y-%m-%d', Date::ITALY).strftime
# => "0011-01-10" I would wager that it's because Ruby |
Any ideas how to fix that issue(s)? PS. I have ruby 1.9.3 |
Looks like another issue reported is here: #116 |
It happens because Timecop uses
Time.strptime("11-01-08", '%Y-%m-%d').to_date
#=> #<Date: 0011-01-10 ((1725085j,0s,0n),+0s,2299161j)> is equivalent to: (the unpatched) Date.strptime("11-01-08", '%Y-%m-%d', Date::GREGORIAN).new_start
#=> #<Date: 0011-01-10 ((1725085j,0s,0n),+0s,2299161j)> |
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 |
Solution is here: #217 |
with Timecop:
|
Submitted a new pr: #242. Fixed tests (mostly Gemfile updates). |
I changed to use DateTime.strptime("11-01-08", '%Y-%m-%d').to_date
=> Thu, 08 Jan 0011 |
I'm closing this issue because the original behavior mentioned has changed. It doesn't seem to be a bug anymore. I have created a new issue for the behavior that @lisbethmarianne mentioned in her comment tho. It can be found here #380 |
I have following situation:
Even
Date::ITALY
works as it should:The text was updated successfully, but these errors were encountered: