Python夏令时
问题描述:
如何检查夏令时是否有效?
How do I check if daylight saving time is in effect?
答
您可以使用 time.localtime
并查看 tm_isdst 标志。
>>> import time
>>> time.localtime()
(2010, 5, 21, 21, 48, 51, 4, 141, 0)
>>> _.tm_isdst
0
使用 time.localtime()
,您可以在任意时间问相同的问题,以了解DST在当前时区是否有效。
Using time.localtime()
, you can ask the same question for any arbitrary time to see whether DST would be (or was) in effect for your current time zone.