I wrote such a code to get timezone based on DST for an specific epoch time:
def getTimeZoneFromEpoch(epoch)
if time.daylight and time.gmtime(epoch).tm_isdst==1:
return -time.altzone/3600.0
else:
return -time.timezone/3600.0
But i’m not sure its correct, in fact at the moment i mistakes by 1 hour. Maybe i should swap altzone and timezone
in this code, but its not what i understood from python’s help (time module):
timezone -- difference in seconds between UTC and local standard time
altzone -- difference in seconds between UTC and local DST time
tm_isdst
1 if summer time is in effect, 0 if not, and -1 if unknown
Have i misundestood something?
I’ve tested this code to obtain the VM’s locale UTC offset. Which, by the way, is only really valid at the moment it is measured. I’m not sure whether your code is equivalent or not.