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


Groups > comp.lang.python > #52793

Re: utcoffset v. _utcoffset

From Ned Deily <nad@acm.org>
Subject Re: utcoffset v. _utcoffset
Date 2013-08-21 13:33 -0700
References <CANc-5UwRWF343mmOeCJhKj6KaU1m4=qGXHrb3PXv1X5_OD-cgA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.103.1377117250.19984.python-list@python.org> (permalink)

Show all headers | View raw


In article 
<CANc-5UwRWF343mmOeCJhKj6KaU1m4=qGXHrb3PXv1X5_OD-cgA@mail.gmail.com>,
 Skip Montanaro <skip@python.org> wrote:

> Consider this little Python script:
> 
> import dateutil.parser
> import pytz
> 
> x = dateutil.parser.parse("2013-08-16 23:00:00+01:00")
> localtz = pytz.timezone("America/Chicago")
> y = localtz.normalize(x)
> 
> When I execute it (Python 2.7.2, dateutil 1.5, pytz 2011h), I get this
> traceback:
> 
> Traceback (most recent call last):
>   File "/home/skipm/tmp/localtzex.py", line 8, in <module>
>     y = localtz.normalize(x)
>   File "/opt/TWWfsw/python27p/lib/python2.7/site-packages/pytz/tzinfo.py",
> line 233, in normalize
>     offset = dt.tzinfo._utcoffset
> AttributeError: 'tzoffset' object has no attribute '_utcoffset'
> 
> Looking at the tzinfo attribute, I see that it has "utcoffset", but
> not "_utcoffset".  I realize those are the latest, most up-to-datest
> versions of all three elements.  I'm having trouble updating dateutil
> and pytz on my Mac at home (stuck on even older versions).  Can
> someone with newer versions of dateutil and pytz see if this problem
> is still present?

I believe the problem is that you are using them incorrectly.  
IAMNADatetimeExpert, but I think you are trying to normalize a 
non-tz-aware datetime object returned from dateutil.parser.parse.

-- 
 Ned Deily,
 nad@acm.org

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


Thread

Re: utcoffset v. _utcoffset Ned Deily <nad@acm.org> - 2013-08-21 13:33 -0700

csiph-web