Comments (6)
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
from timecop.
@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.
from timecop.
thanks for the bug report @krzyzak are you interested in sending a PR with tests that demonstrate the fix?
from timecop.
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 Date.strptime
behaves like the Ruby Date.strptime
, or this an expected/desired behaviour to default to the current month?
from timecop.
@joshuacronemeyer yes, that indeed fixes my issue. Is there an option to release new gem version?
from timecop.
@krzyzak thanks for asking. I just released 0.9.5 that includes this change. Would appreciate you bumping your version and testing.
from timecop.
Related Issues (20)
- Is call to Timecop.travel(some random time) atomic in nature? HOT 1
- Time#travel should be side-effect free and not resume system clock HOT 10
- .
- Timecop.thread_safe = true by default HOT 1
- Timecop handles GMT/UTC Time objects incorrectly HOT 2
- Doesn't work for `Rails.cache` with `expires_in` HOT 2
- ruby 3.1 support
- %W is not handled properly HOT 1
- Ruby 2.5 seems to work? HOT 4
- Using timecop with psych 4.0.5, behavior differs between the test environment and other environments HOT 3
- Timecop.scale to mock existing times HOT 2
- Timecop.freeze not working with expect().to receive HOT 3
- Test
- Need a proper test for making sure we don't change timezones inadvertently
- DateTime parse without date not working properly HOT 5
- DateTime.parse("Wednesday 12:00") format is always returning midnight HOT 1
- Time.now sometimes has greater-than-nanosecond precision when called under Timecop.travel HOT 3
- DateTime.parse does not handle CWeek correctly
- Mocking `Process.clock_gettime` causes `Concurrent::IVar` with timeout to wait indefinitely HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timecop.