Last active
May 7, 2024 13:07
-
-
Save michelbl/e1052bbb517357c796cb5fccaba8ba04 to your computer and use it in GitHub Desktop.
A list of surprises, using datetimes with the python ecosystem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import UTC | |
from zoneinfo import ZoneInfo | |
TZ_PARIS = ZoneInfo("Europe/Paris") | |
TZ_UTC = UTC | |
# datetime equality is bugged | |
datetime(2023, 10, 29, 2, 30, fold=0, tzinfo=TZ_PARIS) == datetime(2023, 10, 29, 2, 30, fold=1, tzinfo=TZ_PARIS) # True | |
datetime(2023, 10, 29, 2, 30, fold=0, tzinfo=TZ_PARIS).timestamp() == datetime(2023, 10, 29, 2, 30, fold=1, tzinfo=TZ_PARIS).timestamp() # False | |
# good literature: | |
# https://blog.ganssle.io/articles/2018/02/aware-datetime-arithmetic.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment