2013-12-02 12:15:25 |
Jan Spurny |
description |
Creating datetime.time with dateutil.tz.tzlocal fails creates valid datetime.time object, but this object raises error when __str__, __repr__ or isoformat method is called on it.
Demonstration:
>>> import datetime
>>> import dateutil.tz
>>> t1 = datetime.time(1, 2, tzinfo=dateutil.tz.tzutc())
>>> t2 = datetime.time(1, 2, tzinfo=dateutil.tz.tzlocal())
>>> t1
datetime.time(1, 2, tzinfo=tzutc())
>>> t2
datetime.time(1, 2, tzinfo=tzlocal())
>>> print t1
01:02:00+00:00
>>> print t2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/dateutil/tz.py", line 92, in utcoffset
if self._isdst(dt):
File "/usr/lib/pymodules/python2.6/dateutil/tz.py", line 134, in _isdst
+ dt.second)
AttributeError: 'NoneType' object has no attribute 'toordinal'
My locale timezone is "Europe/Prague", python2.6, dateutil 1.4.1, debian linux. |
Creating datetime.time with dateutil.tz.tzlocal creates valid datetime.time object, but this object raises error when __str__, __repr__ or isoformat method is called on it.
Demonstration:
>>> import datetime
>>> import dateutil.tz
>>> t1 = datetime.time(1, 2, tzinfo=dateutil.tz.tzutc())
>>> t2 = datetime.time(1, 2, tzinfo=dateutil.tz.tzlocal())
>>> t1
datetime.time(1, 2, tzinfo=tzutc())
>>> t2
datetime.time(1, 2, tzinfo=tzlocal())
>>> print t1
01:02:00+00:00
>>> print t2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/dateutil/tz.py", line 92, in utcoffset
if self._isdst(dt):
File "/usr/lib/pymodules/python2.6/dateutil/tz.py", line 134, in _isdst
+ dt.second)
AttributeError: 'NoneType' object has no attribute 'toordinal'
My locale timezone is "Europe/Prague", python2.6, dateutil 1.4.1, debian linux. |
|