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: 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: References: Date: Fri, 15 Aug 2014 13:59:42 +1000 Subject: Re: timedelta problem From: Chris Angelico Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Fri, Aug 15, 2014 at 1:51 PM, Denis McMahon 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