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


Groups > comp.lang.python > #76348

Re: timedelta problem

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 <ian.g.kelly@gmail.com>
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&gt;': 0.22; '&gt;&gt;&gt;': 0.24; 'subject:problem': 0.24; 'looks': 0.24; '&gt;': 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 <ian.g.kelly@gmail.com>
Date Thu, 14 Aug 2014 21:37:42 -0600
Subject Re: timedelta problem
To Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13023.1408073905.18130.python-list@python.org> (permalink)
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

Show key headers only | 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