Question

I am reading on SO that the Python standard library does not define any time-zones.

Also, from the Python 2.7 datetime docs:

Note that no concrete tzinfo classes are supplied by the datetime module.

However, calling utcnow() generates the current time in UTC. Furthermore, Python can also provide the current local time with now(). I am assuming that this is only possible if Python "knows" the local time-to-UTC offset (in order to return the correct values).

But doesn't that mean that Python is timezone aware? What am I missing?

Was it helpful?

Solution

Your OS provides the current timezone, as well as UTC time.

The OS does not, however, provide other timezone info, such as when DST switches take place. In other words, you can get the current time in the UTC timezone, but not accurately calculate local time across the year, as the offset to UTC changes with the summertime and wintertime switches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top