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


Groups > comp.lang.python > #76351

Re: timedelta problem

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'attribute': 0.07; 'valueerror:': 0.09; 'cc:addr:python-list': 0.11; '36,': 0.16; '46,': 0.16; 'directive': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mess,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'subject:problem': 0.24; 'cc:2**0': 0.24; '15,': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; '(my': 0.31; 'fri,': 0.33; 'skip:t 40': 0.33; 'skip:d 20': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'two': 0.37; 'pm,': 0.38; 'bad': 0.39; 'between': 0.67; '3.4': 0.84; 'clearer': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=0LpBpCnCqY/rCddjNDgGAaYleRnqtu8iQiVCOeA/+9w=; b=zrugNfe9qunYnGZQaKWrcoArpSLmtScpb1fpamORrfG8n7YsoaNnOPEx8sHgaY7lVQ yStkDr5miPGDKla8+jE3qS2wnfKFHSVbVVlOzWGrBbcKgUX6LzXv3tnlZ6SJzJ2tKjWR bSXNIAHlmkq/4XPRO9sF1U/4uhhY4QBkDs9tDCddkXC2vVX0xLmLc9fvb5Chi7hoZ/U9 OB4ACqZNLdPusKOs/+BOpI5s1ZqdwhUlL5vpOTvURt3tneV7GzgR/hLzE/TZ8RtJeblK lCdvJh7NAa+gjegRvjDrGKjbWLZoahOSwKElBFCAYYoIeUtnTOhKp8a+B2D0fE8htvLE 5Fdw==
MIME-Version 1.0
X-Received by 10.50.30.72 with SMTP id q8mr63380596igh.14.1408075183034; Thu, 14 Aug 2014 20:59:43 -0700 (PDT)
In-Reply-To <lsk03m$osa$8@dont-email.me>
References <mailman.13018.1408069502.18130.python-list@python.org> <lsk03m$osa$8@dont-email.me>
Date Fri, 15 Aug 2014 13:59:42 +1000
Subject Re: timedelta problem
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.13025.1408075186.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408075186 news.xs4all.nl 2935 [2001:888:2000:d::a6]:42766
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76351

Show key headers only | View raw


On Fri, Aug 15, 2014 at 1:51 PM, Denis McMahon <denismfmcmahon@gmail.com> wrote:
> On Fri, 15 Aug 2014 10:24:47 +0800, 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")
>
> Are you sure? When I try this I get:
>
> ValueError: 'z' is a bad directive in format '%a, %d %b %Y %H:%M:%S %z'
>
>> datetime.datetime(2014, 8, 9, 7, 36, 46,
>> tzinfo=datetime.timezone(datetime.timedelta(-1, 61200)))
>
> And this:
>
> AttributeError: 'module' object has no attribute 'timezone'

Both fail as you describe in 2.7, but in 3.4/3.5ish (my 'python3' is a
bit of a mess, but it's something between those two I think), both
work as per the OP's description. You both need to be clearer about
version numbers, I think :) The OP did have a link to docs with 3.4 in
the name, although that isn't proof necessarily.

ChrisA

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


Thread

timedelta  problem luofeiyu <elearn2014@gmail.com> - 2014-08-15 10:24 +0800
  Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 03:51 +0000
    Re: timedelta problem Chris Angelico <rosuav@gmail.com> - 2014-08-15 13:59 +1000
    Re: timedelta problem Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-14 22:00 -0600
  Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 07:39 +0000
    Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 08:44 +0000
    Re: timedelta problem Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-15 09:23 -0600
      Re: timedelta problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 17:43 +0000
        Re: timedelta problem Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-15 12:05 -0600
    Re: timedelta problem Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-15 17:29 +0100
  Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 09:36 +0000

csiph-web