problem with strptime and time zone

m_ahlenius ahleniusm at
Tue Aug 24 22:45:12 CEST 2010


perhaps I missed this posted already somewhere.

I am got a program which reads time stings from some devices which
are  providing the time zones.  I have to take this into account when
doing some epoch time calculations.

When I run the following code with the time zone string set to 'GMT'
it works ok.

This works:

myStrA = 'Sun Aug 22 19:03:06 GMT'

gTimeA = strptime( myStrA, '%a %b %d %H:%M:%S %Z')

print "gTimeA = ",gTimeA


But when its set to 'PDT' it fails.

Any ideas?

whereas this fails:
myStrA = 'Sun Aug 22 19:03:06 PDT'
gTimeA = strptime( myStrA, '%a %b %d %H:%M:%S %Z')
print "gTimeA = ",gTimeA

ValueError: time data 'Sun Aug 22 19:03:06 PDT' does not match format
'%a %b %d %H:%M:%S %Z'

thank you,

More information about the Python-list mailing list