Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76348

Re: timedelta problem

References <53ED6F6F.2030004@gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-08-14 21:37 -0600
Subject Re: timedelta problem
Newsgroups comp.lang.python
Message-ID <mailman.13023.1408073905.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu <elearn2014@gmail.com> wrote:
> 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

You have it backwards. t1 is a later time than t2.

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

>>> dt1 - dt2
datetime.timedelta(0, 50400)
>>> _.seconds // 3600
14

Looks correct to me.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: timedelta problem Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-14 21:37 -0600

csiph-web