469,626 Members | 1,812 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

[dateutil] bug(s) in dateutil.parser /dateutil.tz

Hi all,

I'm having some problems with python-datetutil (which is a very, very nice tool, btw). Anybody knows where to adress these other than here? I tried reaching the author but don't seem to get through.

Anyhow:
1. There's a bug in dateutil.parser you run into when you try to use a custom parserinfo. This patch fixes it:

*** /data/pydev/DOWNLOADS/python-dateutil-1.1/dateutil/parser.py.ORIG Mon Nov 6 15:39:26 2006
--- /data/pydev/DOWNLOADS/python-dateutil-1.1/dateutil/parser.py Mon Nov 6 15:39:46 2006
***************
*** 285,291 ****

def __init__(self, info=parserinfo):
if issubclass(info, parserinfo):
! self.info = parserinfo()
elif isinstance(info, parserinfo):
self.info = info
else:
--- 285,291 ----

def __init__(self, info=parserinfo):
if issubclass(info, parserinfo):
! self.info = info()
elif isinstance(info, parserinfo):
self.info = info
else:
2. There is another bug in dateutil.tz in the tzfile class.
This is a section of the Solaris MET zoninfo file

$ zdump -v MET|grep 1982
MET Sun Mar 28 00:59:59 1982 UTC = Sun Mar 28 01:59:59 1982 MET isdst=0
MET Sun Mar 28 01:00:00 1982 UTC = Sun Mar 28 03:00:00 1982 MEST isdst=1
MET Sun Sep 26 00:59:59 1982 UTC = Sun Sep 26 02:59:59 1982 MEST isdst=1
MET Sun Sep 26 01:00:00 1982 UTC = Sun Sep 26 02:00:00 1982 MET isdst=0

Using this with tz.tzfile:
>>from dateutil import tz
import datetime
tz.TZPATHS.insert(0, "/usr/share/lib/zoneinfo")

datetime.datetime(1982, 9, 25, 22, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 0, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))
>>print datetime.datetime(1982, 9, 25, 22, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 00:59:00+02:00
>>>
datetime.datetime(1982, 9, 25, 23, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 2, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))
>>print datetime.datetime(1982, 9, 25, 22, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 00:59:00+02:00
>>print datetime.datetime(1982, 9, 25, 23, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 02:59:00+01:00
>>>
datetime.datetime(1982, 9, 26, 0, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 3, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))
>>print datetime.datetime(1982, 9, 26, 0, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 03:59:00+01:00
>>>
datetime.datetime(1982, 9, 26, 1, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 4, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))
>>print datetime.datetime(1982, 9, 26, 1, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 04:59:00+01:00
>>>
datetime.datetime(1982, 9, 26, 2, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 3, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))
>>print datetime.datetime(1982, 9, 26, 2, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 03:59:00+01:00
>>>
Note how the MET local time is wrong at 23:59UTC, 0:59UTC and 01:59UTC.

I've looked at the code but currently don't really understand how the default tzfinfo.fromutc implementation, as quoted in the python datetime documentation, is supposed to work in the first place.

Any ideas?

Cheers,
Holger
--
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
Apr 5 '07 #1
0 1189

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Stuart D. Gathman | last post: by
2 posts views Thread by Chris Green | last post: by
4 posts views Thread by Howard Jess | last post: by
1 post views Thread by Hong Hao | last post: by
4 posts views Thread by mitsura | last post: by
7 posts views Thread by Daniel T. | last post: by
1 post views Thread by dmbkiwi | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
12 posts views Thread by Juan T. Llibre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.