Skip to content

Instantly share code, notes, and snippets.

@michelbl
Created December 12, 2023 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michelbl/e1052bbb517357c796cb5fccaba8ba04 to your computer and use it in GitHub Desktop.
Save michelbl/e1052bbb517357c796cb5fccaba8ba04 to your computer and use it in GitHub Desktop.
A list of surprises, using datetimes with the python ecosystem
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment