timedelta problem

luofeiyu elearn2014 at gmail.com
Thu Aug 14 22:24:47 EDT 2014


In the python doc , https://docs.python.org/3.4/library/datetime.html

A timedelta 
<https://docs.python.org/3.4/library/datetime.html#datetime.timedelta> 
object represents a duration, the difference between two dates or times.

/class /datetime.timedelta(/days=0/, /seconds=0/, /microseconds=0/, 
/milliseconds=0/, /minutes=0/, /hours=0/, /weeks=0/)

    All arguments are optional and default to 0. Arguments may be
    integers or floats, and may be positive or negative.

    Only /days/, /seconds/ and /microseconds/ are stored internally.

import datetime
t1='Sat, 09 Aug 2014 07:36:46 -0700'
t2='Sat, 09 Aug 2014 07:36:46 +0700'
 >>> datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z")
datetime.datetime(2014, 8, 9, 7, 36, 46, 
tzinfo=datetime.timezone(datetime.timed
elta(-1, 61200)))
 >>> datetime.datetime.strptime(t2,"%a, %d %b %Y %H:%M:%S %z")
datetime.datetime(2014, 8, 9, 7, 36, 46, 
tzinfo=datetime.timezone(datetime.timed
elta(0, 25200)))


problem :

t1 is GMT time   2014  00:36:46
t2 is GMT time   2014  14:36:46

datetime.datetime.strptime  do not give me the right answer.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140815/4cacabf6/attachment.html>


More information about the Python-list mailing list