Working with Time Zones in Python
The due dates stored in the database are naive datetimes. That means they do not have a time zone associated with them. So while we can see a date and time, the datetime object is unaware of when that datetime is. What time zone at almost midnight are we talking about?
Standard practice is to store all due dates in UTC format, then change them to the relevant time zone as needed.
pytz is a 3rd-party application that helps with time zones, including daylight savings. From their documentation: pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher. It also solves the issue of ambiguous times at the end of daylight saving time, which you can read more about in the Python Library Reference (
You will need basic Python programming and datetime skills for this lab: