문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top