【发布时间】:2015-10-12 18:09:01
【问题描述】:
我希望使用“US/Central”替换 tzinfo 会得到与使用时区对象 (pytz.timezone('US/Central')) 相同的结果,但显然不是:
In [5]: import arrow
In [6]: d = arrow.get()
In [7]: cst = pytz.timezone('US/Central')
In [8]: d.replace(tzinfo=cst)
Out[8]: <Arrow [2015-07-22T17:40:30.947579-06:00]>
In [9]: d.replace(tzinfo='US/Central')
Out[9]: <Arrow [2015-07-22T17:40:30.947579-05:00]>
注意第 8 行的输出与第 9 行的输出有不同的 UTC 偏移量。
哪种方法是使用 Arrow 和 pytz 替换时区的正确方法?
【问题讨论】: