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


Groups > comp.lang.python > #76348 > unrolled thread

Re: timedelta problem

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2014-08-14 21:37 -0600
Last post2014-08-14 21:37 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#76348 — Re: timedelta problem

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-08-14 21:37 -0600
SubjectRe: timedelta problem
Message-ID<mailman.13023.1408073905.18130.python-list@python.org>

[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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web