I am having trouble with time zones in python and have a curious example... I am using Python 2.7.2
import time
import datetime
import pytz
utc = pytz.utc
est = pytz.timezone('US/Eastern')
mst = pytz.timezone('US/Mountain')
print 'UTC time',time.mktime(datetime.datetime(1970, 01, 01, 0, 0, 0, tzinfo=utc).timetuple())/3600
print 'EST time',time.mktime(datetime.datetime(1970, 01, 01, 0, 0, 0, tzinfo=est).timetuple())/3600
print 'MST time',time.mktime(datetime.datetime(1970, 01, 01, 0, 0, 0, tzinfo=mst).timetuple())/3600
I thought that I should get 0.0, 5.0, and 7.0 for the three examples (UTC,EST,MST) - however I get 5.0 for all three cases (My computer is operating in EST).
additionally
time.mktime(time.gmtime(0))
returns 18000.0 (5 hours) - so - explicitly requesting gmtime for a tuple and then converting to epoch returns 5 hours. My python distribution has time.time() and time.gmtime(), but not time.timegm()
So, if I receive data from a customer in MST - and want to generate an epoch in UTC - must I just pretend that the time stamps are in EST and then add five hours?
is this a result of strptime throwing away time zone info?