dateutil似乎给了错误的时区

问题描述

我使用datetimedateutil获取当前的UTC偏移量和时区,如下所示:

>>> from datetime import datetime
>>> from dateutil.tz import tzlocal
>>>
>>> current_time = datetime.Now(tzlocal())
>>> print('Your UTC offset is {:+g}'.format(current_time.utcoffset().total_seconds()/3600))
Your UTC offset is +2
>>> print('Your time zone is {}'.format(current_time.tzname()))
Your time zone is W. Europe Daylight Time

UTC偏移量正确,但时区错误我有中欧夏令时;此外,西欧夏令时间为UTC + 1,因此它甚至与打印的UTC偏移量都不匹配。那么为什么此代码显示“ W. Europe Daylight Time”而不是“ C. Europe Daylight Time”?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)