PYTZ 'America/Edmonton' offset wrong [duplicate]

天涯浪子 提交于 2019-12-05 08:15:32

The documentation for pytz explicitly says that creating a datetime directly from a timezone won't work in all cases, and directs you to do the following instead:

d2 = timezone('America/Edmonton').localize(d)

Looking at the 2012c TZDB data, here's the rule set for America/Edmonton:

Zone America/Edmonton    -7:33:52 -       LMT   1906 Sep
                         -7:00    Edm     M%sT  1987
                         -7:00    Canada  M%sT

It's not clear to me what date/time the Python output is trying to show you the offset/name for, but I suspect it's something like 1900 - in which case the 16:26:00 makes some sense with the offset of -7:33:52, and it would match the abbreviation, too.

So it's entirely feasible that the time zone data is fine, and it's just choosing to show you an odd date/time as an example. (It makes no sense to me that the string output of a time zone would show a time at all, to be honest...)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!