Monitor performance issues & errors in your code

Unlock the mysteries of time, Python's datetime that is!

Episode #271, published Sat, Jul 4, 2020, recorded Thu, Jun 18, 2020

Time is a simple thing, right? And working with it in Python is great. You just import datetime and then (somewhat oddly) use the datetime class from that module.

Oh except, there are times with timezones, and times without. And why is there a total_seconds() but not total_minutes(), hours() or days() on timedelta? How about computing the number of weeks?

What if you wanted to iterate over the next 22 workdays, skipping weekends?

Ok, we'd better talk about time in Python! Good thing Paul Ganssle is here. He's a core developer who controls time in CPython.
Links from the show

Talk Python Training Humble Bundle:

Paul on Twitter: @pganssle
Paul's Blog:
Paul's Website:

Datetime blog posts
pytz: The fastest footgun in the West:
Stop using utcnow and utcfromtimestamp:
A curious case of non-transitive datetime comparison:
Semantics of timezone-aware datetime arithmetic:


PEP 495: Local time disambiguation:
PEP 615: Support for the IANA Time Zone Database in the Standard Library:

zoneinfo documentation in Python 3.9:

Extra libraries

Indiana Time Zones:
Episode transcripts:

--- Stay in touch with us ---
Subscribe to us on YouTube:
Follow Talk Python on Mastodon: talkpython
Follow Michael on Mastodon: mkennedy

Want to go deeper? Check out our courses

Talk Python's Mastodon Michael Kennedy's Mastodon