Skip to content

Instantly share code, notes, and snippets.

View michelbl's full-sized avatar

Michel Blancard michelbl

View GitHub Profile
@michelbl
michelbl / datetime_surprises.py
Last active May 7, 2024 13:07
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