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


Groups > comp.lang.python > #76351

Re: timedelta problem

References <mailman.13018.1408069502.18130.python-list@python.org> <lsk03m$osa$8@dont-email.me>
Date 2014-08-15 13:59 +1000
Subject Re: timedelta problem
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.13025.1408075186.18130.python-list@python.org> (permalink)

Show all headers | 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