Issue
How do I check if daylight saving time is in effect?
Solution
You can use time.localtime
and look at the tm_isdst
flag in the return value.
>>> import time
>>> time.localtime()
(2010, 5, 21, 21, 48, 51, 4, 141, 0)
>>> _.tm_isdst
0
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.
Answered By - Greg Hewgill
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.