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
Date.strptime returns wrong month for %Y #377
Comments
thanks for the bug report @krzyzak are you interested in sending a PR with tests that demonstrate the fix? |
I was looking into opening a PR for this issue, but from the short investigation that I did it seems that this is a very explicit expected behaviour. timecop/lib/timecop/time_extensions.rb Lines 53 to 56 in 8ca1018
I guess to change to the expected behaviour described in this issue it would need to change to something like d = Date._strptime(str, fmt) || Date.strptime_without_mock_date(str, fmt)
now = Time.now.to_date
year = d[:year] || now.year
mon = d[:mon] || 1 which feels like a large change from the perspective of expectation of how this method works (on timecop). So I think that the main question is: Should the timecop |
Thanks guys. The Timecop implementation of strptime is a work in progress. Our implementation is incomplete and we're slowly chipping away at it. It should behave like the ruby implementation. checkout timecop/test/date_strptime_scenarios.rb Lines 68 to 81 in 8ca1018
|
@krzyzak and @augustoccesar i'd appreciate if you'd have a look at my PR #379 for this issue. I'm open to suggestions on ways to better implement this. |
@joshuacronemeyer yes, that indeed fixes my issue. Is there an option to release new gem version? |
@krzyzak thanks for asking. I just released 0.9.5 that includes this change. Would appreciate you bumping your version and testing. |
Hey,
Today I found issue with
Date.strptime
: it falls back to current month, rather than returning Jan 1st, when parsing just%Y
:Seems that the issue lies in time_extensions.rb.
The text was updated successfully, but these errors were encountered: