~/talk

Handling Timezones in Python

Talkat PyCon US 2022 · 2022-04-27..05-03· [web-platform, python]
links:none on file
slides:none on file

Claims that naive datetimes cause up to 26 hours of ambiguity and that duration arithmetic must run in UTC; demonstrates actual code recipes using Python 3.9+ zoneinfo (or the backport plus tzdata) and Django settings (USE_TZ, timezone.activate, make_aware). Shows surprising pytz failure (example producing a UTC offset of 4h56m), gives concrete fixes: construct timezone-aware datetimes, store and compute in UTC, do calendar math on dates, convert to user timezone for display — code and slides provided.

AI-written summary · about

  1. 0:00Start
  2. 0:44Motivation
  3. 2:59Outline
  4. 3:56Don't use naive datetimes
  5. 6:51Don't use dates without a timezone
  6. 8:35Don't do duration arithmetic outside of UTC
  7. 16:59Maximum compatibility
  8. 17:59Get current time
  9. 18:54Convert datetime to a date in a timezone
  10. 21:13Duration math on UTC datetimes
  11. 21:42Calendar math on dates
  12. 22:55Django timezone setup
  13. 23:38Templates automatically convert to localtime
  14. 24:25Converting to localtime
  15. 24:40Attaching a timezone to a naive datetime
  16. 25:14Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.