【发布时间】:2018-06-27 12:42:34
【问题描述】:
在发布此内容之前,我已经进行了大量研究,但我似乎无法正确转换。我有一些带有时间戳的数据,有些应用了 DST,而另一些则没有。我认为指定它没有 DST 的正确方法是使用 pytz 的 is_dst 参数。所有 3 个选项都给出了与 UTC 相同的偏移量,这是不正确的。偏移量应为 +1000。进行这种转换的最佳方法是什么,为什么 is_dst 参数没有任何区别?
pytz_eastern.localize(datetime(2018, 1, 18, 18, 50), is_dst=None).strftime('%Y-%m-%d %H:%M %z')
'2018-01-18 18:50 +1100'
pytz_eastern.localize(datetime(2018, 1, 18, 18, 50), is_dst=False).strftime('%Y-%m-%d %H:%M %z')
'2018-01-18 18:50 +1100'
pytz_eastern.localize(datetime(2018, 1, 18, 18, 50), is_dst=True).strftime('%Y-%m-%d %H:%M %z')
'2018-01-18 18:50 +1100'
【问题讨论】:
-
“对于大多数时间戳,is_dst 参数被忽略。它仅在 DST 转换模糊期间使用以消除这种模糊性。” pytz_eastern 的转换是什么?
-
夏令时从 10 月的第一个星期日开始,到 4 月的第一个星期日结束。 2017 年 10 月 1 日 - 2018 年 4 月 1 日
标签: python-3.x datetime utc dst pytz