| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
|
||
| def test_replace_tzinfo(): | ||
| d = pendulum.datetime(2016, 7, 2, 0, 41, 20) | ||
| def test_replace_tzinfo_dls_off(): |
There was a problem hiding this comment.
Why dls here and not dst?
Sorry, something went wrong.
There was a problem hiding this comment.
Oh right - I think I started off calling it "dls" (daylight-savings), but later saw that "dst" was a more common way to name it.
I'll rename to "dst".
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed with a fixup commit (i.e. I can squash into one commit before merge if you like, unless if you want to just squash+merge)
Sorry, something went wrong.
|
Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
After doing a lot of experiments, it seemed to me that there was a problem when calling .replace() during DST off-transition (i.e. in the immediate hour after the transition). Reported issue here: #415.
So a seemingly innocent code like this:
would change the datetime in more ways than simply setting microseconds to zero.
This patch makes it so that when .replace() is called, it respects the .fold flag set on the datetime itself, which seems to resolve the issue.
Now, I'm no expert in timezones myself, so this might definitely be the exact wrong approach - but my gut feeling told me that it seemed odd to just default to the pendulum.POST_TRANSITION rule anytime we do replace, so I figured utilizing the flag seemed the right way to go about it. Seemed more symmetrical to the surrounding code too.
I added one more test module, to explicitly test out the .replace() function. Wasn't sure where best to fit it, but can easily accommodate a different place for it. As it happened, one of the "fluent" tests also broke - one that is dong a .replace(tzinfo=...) call. So I suppose I could have put my replace tests there, but wasn't sure what "fluent" meant in this context. So I ended up adding a few more cases for those .replace(tzinfo= tests, to get solid coverage surrounding DST transition points. Not quite convinced if those tests are what you had in mind when you wrote the original test, so hoping I'm not deviating from the intended design.
Well - looking forwards to your feedback - feel free to push back on any/all of this.