I'm wrestling with what appears to be a common timezone issue in Python, but have not been able to solve it or find the exact issue I'm running into here on SO, so I pose the question below.
I have a timetuple that does not have a timezone set. I also have a timezone. And I have the computer in a different timezone. How do I convert the time to the local time taking DST into account?
>>> type(dt.value)
<type 'datetime.datetime'>
>>> print dt.timetuple()
time.struct_time(tm_year=2012, tm_mon=6, tm_mday=28, ..., tm_isdst=-1)
>>> print somezone.zone
America/New_York
If I add the zone info to dt
as follows, DST isn't handled properly... tm_isdst
always shows up as zero, regardless of the month being in DST or not.
dt.value = dt.value.replace(tzinfo=somezone)
>>> print dt.timetuple()
time.struct_time(tm_year=2012, tm_mon=6, tm_mday=28, ..., tm_isdst=0)