-
Notifications
You must be signed in to change notification settings - Fork 15
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
Handle invalidation of zoned datetimes due to changes to timezone definition #39
Comments
We don't even have to wait until 2030. Muslim countries observing Ramadan can change their UTC offsets 4 times a year, with the exact DST transition date/time depending on the phase of the moon and the judgement call of a human observer. The actual transition times can vary by a few days every year, at the last minute. The problem is that most Another implication of this is that most libraries try very hard to avoid constructing a I don't have a perfect solution to offer here. Temporal's solution seems pretty good at first glance, with the caveat that it's another complex edge case that needs to be explained, and most end-users will have trouble understanding. |
It's indeed a tricky case in the category "the vast majority of users won't encounter this, but the API needs to be rock-solid in case it does happen". My current thinking is:
concrete solutionadding a use-case 1: picklingzdt = ZonedDateTime(2020, 1, 1, tz="Europe/Amsterdam", unpickle_offset_conflict="preserve_instant")
pkl = pickle.dumps(zdt) # stores the tz offset behavior
# Amsterdam changes its tz here...
new_zdt = pickle.loads(pkl) # handled according to `preserve_instant`, as explicitly configured use-case 2: updating
|
How to handle this
i.e. imagine you store
ZonedDateTime(2030, 3, 31, hour=1, tz='America/New_York')
which we expect to exist at this moment. However, by the time 2030 rolls around NYC has decided to implement summer time at this exact time, making the datetime invalid. How to handle this?Note that timezone changes during the runtime of the program will likely never be handled. This would be terrible to implement, and I doubt there is a use case for this.
However, unpickling and
from_canonical_str()
will be affected. Perhaps a similar approach to JS temporal can be used.The text was updated successfully, but these errors were encountered: