Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; '36,': 0.16; '46,': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'later': 0.20; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'email addr:gmail.com>': 0.22; '>>>': 0.24; 'subject:problem': 0.24; 'looks': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'message-id:@mail.gmail.com': 0.30; 'skip:d 20': 0.34; 'problem': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:t 30': 0.61; 'answer.': 0.68 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=wDK8ekcugWP8tSJWr4fRWtaztMRBxdOFLAtnNX/RIPo=; b=Vl1P94MqS8MmCgQu+Sm0VE14QluKB6T4aF7zvnlGzMdsF9f107j07PZpshgS4opyiH B1TVOkuipN/aM4HXyl7f7aP+qzeKt9pnn88pRhWCvYOYLqLo82wRd/qu6sonmedsSU7R KExg4Q6RS3W1LjWTYliyZ4tM+ThzyvGxjhRFAD5y0eVBt7C6wG9hHAi9gdUMN7glL1OX zOHzNJCDJvnV2pLyI1s10mUbGO5xuiJumw/8ioM5YZU6DV/f/0icy08pVZo4kaFHhiXG cT8vbby8lan7shnq7diE7Zoxen+kEequioz0ZK2X7CGHhNnnxHBVOJBCEwSsWhphUpiG nODA== X-Received: by 10.66.243.6 with SMTP id wu6mr1647144pac.157.1408073902572; Thu, 14 Aug 2014 20:38:22 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <53ED6F6F.2030004@gmail.com> References: <53ED6F6F.2030004@gmail.com> From: Ian Kelly Date: Thu, 14 Aug 2014 21:37:42 -0600 Subject: Re: timedelta problem To: Python Content-Type: multipart/alternative; boundary=047d7b111b0dc7cc8b0500a2c034 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 61 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408073905 news.xs4all.nl 2950 [2001:888:2000:d::a6]:60938 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76348 --047d7b111b0dc7cc8b0500a2c034 Content-Type: text/plain; charset=UTF-8 On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu 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. --047d7b111b0dc7cc8b0500a2c034 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu <elearn2014@gmail.com> wrote:
> imp= ort datetime
> t1=3D'Sat, 09 Aug 2014 07:36:46 -0700'
>= t2=3D'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=3Ddateti= me.timezone(datetime.timed
> elta(-1, 61200)))
> >>> d= atetime.datetime.strptime(t2,"%a, %d %b %Y %H:%M:%S %z")
> datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=3Ddatetime.timezone(da= tetime.timed
> elta(0, 25200)))
>
>
> problem :
= >
> t1 is GMT time =C2=A0 2014 =C2=A000:36:46
> t2 is GMT ti= me =C2=A0 2014 =C2=A014:36:46

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

<= /div>
> datetime.datetime.strptime =C2=A0do not give me the right an= swer.

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

=
Looks correct to me.
--047d7b111b0dc7cc8b0500a2c034--