import time_travel: A Primer on Timezones in Python
summary
Argues that timezone bugs are avoidable by using concrete tools and patterns: Python's datetime/TZInfo with the fold field for ambiguous times, dateutil's gettz plus resolve_imaginary to shift nonexistent wall times, and pytz's localize/normalize workflow to avoid static-offset surprises. Recommends storing timestamps in UTC, preserving wall time as ISO 8601 plus an IANA name, and keeping the tzdb current (updated several times a year). Shows a monkey‑patch wrapper that preserves TZ names as a workable but hacky serialization.
AI-written summary · about
chapters (23)
- 0:00Intro
- 1:39There is no escape.
- 3:17I work at Clara Labs
- 4:08Timezones contextualize datetimes
- 5:09Coordinated Universal Time
- 5:44IANA Timezone Database
- 7:01Limitations of UTC Offset
- 7:29Ambiguous Times
- 8:14Imaginary Times
- 8:59datetime.tzinfo
- 11:00datetime.datetime
- 16:18dateutil.tz
- 24:26Timezone-Aware Sandwich
- 26:03Keep your IANA data current
- 26:41What do you need to preserve?
- 27:39Serializing a timestamp to ISO 8601
- 27:53Deserializing an ISO 8601 timestamp
- 28:34Serializing a wall time
- 29:44What about strptime/strftime?
- 31:54Postgres datetime types
- 34:11MySQL datetime types
- 36:39Storing wall times
- 37:04Storing timestamps
related talks
30mWorking with Time Zones: Everything You Wish You Didn't Need to Know
28mTime Zones in Python: Everything You Wish You Didn't Need
26mHandling Timezones in Python
18mManaging Time like a Time Lord: It's bigger on the inside
27mThe time paradox: Building Timezone-safe python/django applications.
45mEverything You Never Wanted to Know About Time Zones
38mA Matter of Time
26mIt's about time
