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: humblebundle.com

Paul on Twitter: @pganssle
Paul's Blog: blog.ganssle.io
Paul's Website: ganssle.io

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

PEPs

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

zoneinfo documentation in Python 3.9: docs.python.org
backports.zoneinfo: pypi.org
pytz_deprecation_shim: readthedocs.io

Extra libraries
dateutil: readthedocs.io
break-my-python: pypi.org
arrow: readthedocs.io
pendulum: pendulum.eustace.io

Indiana Time Zones: google.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to us on YouTube: youtube.com
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