Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'attribute': 0.07; 'valueerror:': 0.09; 'python': 0.11; '36,': 0.16; '46,': 0.16; 'directive': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'import': 0.22; 'aug': 0.22; 'email addr:gmail.com>': 0.22; 'subject:problem': 0.24; '>': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'fri,': 0.33; '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; 'bad': 0.39; 'to:addr:python.org': 0.39 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=cdNcj1DjyTL/j5nSXleAuXi2g2fiJw/3EtLyvh3XTnU=; b=HXV/39I4MHUnLfGqleVItR2a/JO0oP+0Yfuf9YEMoBdOduv1DJGwUJgyXMvRUqT1Xz gR5ALBKhGUWlZgpJMZqqCWTASEYmPvXkrKiFbaidE5KXl6izOPiHHWvGNkX0PbQI92ms bkg0Lm07gTs+IyPhsM13VQmuAqCx9goHKObk1XPlwEWAw9gmPU72nnvbmwxQqTI8AykM 2+cXCaaxXjxIQZqwTlOv9SFIlicXw46DZ124MzWrtRqIcKe7kc2pMPNguh9MBJD/6gJL /YpLaCXmgNKG1pe0DFiXisac5uJZQr5v1poh4+XZ3J3CNijbhZMTxa0NWHVK+0zS18WU m4BQ== X-Received: by 10.66.119.174 with SMTP id kv14mr8794838pab.52.1408075298171; Thu, 14 Aug 2014 21:01:38 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Thu, 14 Aug 2014 22:00:58 -0600 Subject: Re: timedelta problem To: Python Content-Type: multipart/alternative; boundary=e89a8ffbaa25f8b0ac0500a31372 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408075301 news.xs4all.nl 2966 [2001:888:2000:d::a6]:45067 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76352 --e89a8ffbaa25f8b0ac0500a31372 Content-Type: text/plain; charset=UTF-8 On Thu, Aug 14, 2014 at 9: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' The datetime.timezone class was added in Python 3.2. --e89a8ffbaa25f8b0ac0500a31372 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Thu, Aug 14, 2014 at 9:51 PM, Denis McMahon <denismfmcmahon@gmail.com> wrote= :
>
> On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote:
&g= t;
> > import datetime
> > t1=3D'Sat, 09 Aug 2014 07:36:46 = -0700'
> > t2=3D'Sat, 09 Aug 2014 07:36:46 +0700'
&= gt; > datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z"= )
>
> Are you sure? When I try this I get:
>
> ValueErro= r: 'z' is a bad directive in format '%a, %d %b %Y %H:%M:%S %z&#= 39;
>
> > datetime.datetime(2014, 8, 9, 7, 36, 46,
> &= gt; tzinfo=3Ddatetime.timezone(datetime.timedelta(-1, 61200)))
>
> And this:
>
> AttributeError: 'module' obj= ect has no attribute 'timezone'

The datetime= .timezone class was added in Python 3.2.
--e89a8ffbaa25f8b0ac0500a31372--