473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

[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 1253

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stuart D. Gathman | last post by:
Running the following with Python 2.2.2: from email.Parser import Parser txt = """Subject: IE is Evil Content-Type: image/pjpeg; name="Jim&amp;&amp;Jill" <html> </html> """
2
by: Chris Green | last post by:
I'm encountering a place where if I use a for loop I can't catch the error raised by a member. I've tested python 2.3 and 2.3.1 ( the only ones I had quickly around ) and it's still occuring. ...
4
by: Howard Jess | last post by:
In Opera 8.01 (Linux; Build 1204) and in Opera 7.54 (Windows XP; Build 3865), my form disappears from the HTML markup (below). To summarize: 1) In a <script> block in the <head> I create a form...
1
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had...
4
by: mitsura | last post by:
Hi, I think I ran into a bug in the XML SAX parser. part of my program consist of reading a rather large XML file (about 10Mb) containing a few thousand elements. I have the following...
7
by: Daniel T. | last post by:
In my compiler, the following works and does as expected: #include <iterator> #include <iostream> #include <vector> #include <algorithm> int main() { using namespace std;
1
by: dmbkiwi | last post by:
I'm using the dateutil module from http://labix.org/python-dateutil. Am I right in thinking that the rrules module doesn't acknowledge days before today? An example of the issue: >>>...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open...
12
by: Juan T. Llibre | last post by:
re: !I found an MSDN document that explains why what I'm trying to do should work Lee, From : http://www.w3.org/TR/REC-xml/ "A special attribute named xml:lang may be inserted in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.