Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'string': 0.09; 'assumed': 0.09; 'release.': 0.09; '2.7': 0.14; '"right"': 0.16; 'ah,': 0.16; 'docs.': 0.16; 'strftime': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'select': 0.22; 'aug': 0.22; 'documented': 0.24; 'subject:problem': 0.24; 'earlier': 0.24; '15,': 0.26; 'equivalent': 0.26; 'skip:" 30': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'says': 0.33; 'url:python': 0.33; 'fri,': 0.33; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:org': 0.36; 'url:library': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'applicable': 0.60; 'ian': 0.60; 'further': 0.61; 'worth': 0.66; 'behavior': 0.77 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=+MlAZwLgVVXl3lPUEPXz7FQMG75TE0vGmH/GL1HZHJA=; b=dfiiUDZwrlJj3NldnQbEFXRlmioX1VwtvO4yI71DCTxAg+hd/ODcag3HvrZMTGrpna EOECxoiqkoX+o/7W1VXAVppmAvvbGHXiKfiK7TGNomgXKkpOCK6TvEQOijlBnkPgOQsx 8sK5JnOnOjhcIyGpSi+y+/UWrYZxQ654WTJQLGp1bDmfuANaWjAd/jNCDmG9cq5rkdqq 1qcdgaaKvLHQMwnn2Z2CCxaFvdiALCcoyVjkq94MaDmJolZZl8TFSBmhD9os5hbjODoh TL1c4nHj0yinDUFqGu6Q5t6fJ3jWvzaOB1uuPXRBNkmpTfWcgFh9nKw0MlA9NGFgPmsD 0KXQ== X-Received: by 10.70.35.207 with SMTP id k15mr19999755pdj.5.1408125978770; Fri, 15 Aug 2014 11:06:18 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Fri, 15 Aug 2014 12:05:38 -0600 Subject: Re: timedelta problem To: Python 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408125988 news.xs4all.nl 2922 [2001:888:2000:d::a6]:56488 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76380 On Fri, Aug 15, 2014 at 11:43 AM, Denis McMahon wrote: > On Fri, 15 Aug 2014 09:23:02 -0600, Ian Kelly wrote: > >> On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon >> wrote: >>> On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: >>> >>> On further inspection, it seems that strptime() in 2.7 doesn't handle >>> %z at all. In 3.2, it ignores the value it gets, because there's no >>> practical way to select the "right" tz string from the offset. >> >> I'm not sure when %z was added, but it's worth noting that it doesn't >> seem to be documented earlier than 3.3. > > There may be some confusion because %z is in the table of strftime and > strptime format chars on the 2.7.8 docs at > > https://docs.python.org/2/library/datetime.html#strftime-and-strptime- > behavior > > but I suspect it's only applicable to strftime in that release. Ah, interesting. I was looking at the time.strptime docs. I incorrectly assumed that since help(datetime.strptime) defers to help(time.strptime), the docs would also. I note it says that "datetime.strptime(date_string, format) is equivalent to datetime(*(time.strptime(date_string, format)[0:6]))", but clearly that's not the case when the format includes %z.