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


Groups > comp.lang.python > #76349

Re: timedelta problem

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; '36,': 0.16; '46,': 0.16; 'skip:d 60': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'later': 0.20; '>>>': 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:t 40': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.35; '14,': 0.36; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'ian': 0.60; '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=yZnV5+raiJ0lUTFECFUVqnpdxUHDT4kQg+jfzJV+wrM=; b=i0wUjnwkISip4GJz4zB6EnlX+iDVrDb/VinrxW5+iUgcaSSLbfrvWyZl2HfUv0Lh/2 ge3FJi3UAgjoIj10qfq1nOAiNpqEf7ELDFUGtQKWICrspVmGryUHnoxEM7xVtm2gEVhq L+MwCTMsPT0SnNSvtWXs/18pEW9O3BdwUHrGE9NSXRSCN+YHMIckWtNW69TgcISazkfT pFxCK/33wivaUNSrMoVQlQhPDzxfGQPtC8+3avGUgVQS7Jk2fsxjEA2kcniZsnqu0S7i Ym3nV7BGGEVaw1fdtfTHiMRv3rDtlzN5bsgX92khgxIsMOc4pFHZnWjRNBXlxgA2FbTT MhIQ==
X-Received by 10.70.137.98 with SMTP id qh2mr3237860pdb.61.1408074334537; Thu, 14 Aug 2014 20:45:34 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CALwzid=0_EfOciS=vMuBrrrsqEncL+_gppETgCyQAXA5QbUdpg@mail.gmail.com>
References <53ED6F6F.2030004@gmail.com> <CALwzid=0_EfOciS=vMuBrrrsqEncL+_gppETgCyQAXA5QbUdpg@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 14 Aug 2014 21:44:54 -0600
Subject Re: timedelta problem
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=001a1136032c870f350500a2da18
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.13024.1408074339.18130.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408074339 news.xs4all.nl 2872 [2001:888:2000:d::a6]:36348
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76349

Show key headers only | View raw


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

On Thu, Aug 14, 2014 at 9:37 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu <elearn2014@gmail.com> wrote:
> > 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.

Also:

>>> dt1.astimezone(datetime.timezone.utc)
datetime.datetime(2014, 8, 9, 14, 36, 46, tzinfo=datetime.timezone.utc)
>>> dt2.astimezone(datetime.timezone.utc)
datetime.datetime(2014, 8, 9, 0, 36, 46, tzinfo=datetime.timezone.utc)

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:44 -0600

csiph-web