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:
datetime.datetime(1982, 9, 26, 0, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))>>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())
1982-09-26 00:59:00+02:00>>print datetime.datetime(1982, 9, 25, 22, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 2, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))>>>
datetime.datetime(1982, 9, 25, 23, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 00:59:00+02:00>>print datetime.datetime(1982, 9, 25, 22, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 02:59:00+01:00>>print datetime.datetime(1982, 9, 25, 23, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 3, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))>>>
datetime.datetime(1982, 9, 26, 0, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 03:59:00+01:00>>print datetime.datetime(1982, 9, 26, 0, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 4, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))>>>
datetime.datetime(1982, 9, 26, 1, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 04:59:00+01:00>>print datetime.datetime(1982, 9, 26, 1, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
datetime.datetime(1982, 9, 26, 3, 59, tzinfo=tzfile('/usr/share/lib/zoneinfo/MET'))>>>
datetime.datetime(1982, 9, 26, 2, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
1982-09-26 03:59:00+01:00>>print datetime.datetime(1982, 9, 26, 2, 59, 0, tzinfo=tz.tzutc()).astimezone(tz.gettz())
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