J
John Hunter
I have a python2.3 datetime instance and a tzinfo instance (eg Eastern
from the python library reference).
What is the best way to convert that datetime instance to seconds
since the epoch, gmtime?
s1 = '2-Apr-04' # before dst
s2 = '5-Apr-04' # after dst
y,month,d,h,m,s,wd,jd,ds = time.strptime(s1, '%d-%b-%y')
dt1 = datetime.datetime(y,month,d,h,m,s,tzinfo=Eastern)
y,month,d,h,m,s,wd,jd,ds = time.strptime(s2, '%d-%b-%y')
dt2 = datetime.datetime(y,month,d,h,m,s,tzinfo=Eastern)
print dt1, Eastern.utcoffset(dt1)
print dt2, Eastern.utcoffset(dt2)
But I'm not sure how to convert this to epoch gmtime ....
Thanks,
John Hunter
from the python library reference).
What is the best way to convert that datetime instance to seconds
since the epoch, gmtime?
s1 = '2-Apr-04' # before dst
s2 = '5-Apr-04' # after dst
y,month,d,h,m,s,wd,jd,ds = time.strptime(s1, '%d-%b-%y')
dt1 = datetime.datetime(y,month,d,h,m,s,tzinfo=Eastern)
y,month,d,h,m,s,wd,jd,ds = time.strptime(s2, '%d-%b-%y')
dt2 = datetime.datetime(y,month,d,h,m,s,tzinfo=Eastern)
print dt1, Eastern.utcoffset(dt1)
print dt2, Eastern.utcoffset(dt2)
But I'm not sure how to convert this to epoch gmtime ....
Thanks,
John Hunter