-
-
Notifications
You must be signed in to change notification settings - Fork 415
Description
Hi sdispater!
First of all - thanks for this library - my company started out with arrow because it seemed easy etc.. But man, are there drawbacks... Pendulum seems to be doing things the right way, so thanks a lot for crafting this.
Now - I've been digging fairly deep into DST transitions recently, and I think I may have discovered 2 small bugs. To start with, I'll start with the (hopefully) more straight-forward one here (the other is #417).
Seems that if one has a datetime in the hour after DST transitions off, and then does a .replace(seconds=0), it messes up the DST information on the DateTime object.
>>> # Daylight savings turning off for US/Pacific in 2019
>>> # happenes on the 3rd of November, at 9:00 UTC
>>> dt = pendulum.datetime(2019, 11, 3, 8, 30, 12)
>>> tz = pendulum.timezone('US/Pacific')
>>> dtz = tz.convert(dt)
>>> print(dtz.isoformat())
2019-11-03T01:30:12-07:00
>>> print(dtz.fold, dtz.is_dst(), -dtz.utcoffset())
0 True 7:00:00
>>> dtz2 = dtz.replace(second=0)
>>> print(dtz2.isoformat())
2019-11-03T01:30:00-08:00
>>> print(dtz2.fold, dtz2.is_dst(), -dtz2.utcoffset())
1 False 8:00:00I took the liberty of trying my hand at a fix: #414.
I set up a small pyfiddle showcasing the behavior: https://pyfiddle.io/fiddle/d80564bc-96ca-4fe8-9e3e-982a474e9e73/?i=true