DateTime trouble parsing daylight savings time

Bug #143884 reported by Jarrod Kinsley
2
Affects Status Importance Assigned to Milestone
DateTime
Invalid
Medium
Unassigned

Bug Description

DateTime is raising a SyntaxError when encountering datetime strings that have daylight savings time zones such as EDT, CDT, MDT, PDT. This can be tested as follows:

[pts6][zope@horus DateTime]$ python
Python 2.4.3 (#1, Jun 14 2006, 14:53:31)
[GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from DateTime import DateTime
>>> dt = DateTime('Wed, 14 Mar 2007 09:44:06 EDT')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/zope2/lib/python/DateTime/DateTime.py", line 555, in __init__
    return self._parse_args(*args, **kw)
  File "/usr/lib/zope2/lib/python/DateTime/DateTime.py", line 798, in _parse_args
    yr,mo,dy,hr,mn,sc,tz=self._parse(arg, datefmt)
  File "/usr/lib/zope2/lib/python/DateTime/DateTime.py", line 1087, in _parse
    raise SyntaxError, st
DateTime.SyntaxError: Wed, 14 Mar 2007 09:44:06 EDT
>>> dt = DateTime('Wed, 14 Mar 2007 09:44:06 EST')
>>> print dt.timezone()
US/Eastern
>>> dt = DateTime('Wed, 14 Mar 2007 09:44:06 CDT')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/zope2/lib/python/DateTime/DateTime.py", line 555, in __init__
    return self._parse_args(*args, **kw)
  File "/usr/lib/zope2/lib/python/DateTime/DateTime.py", line 798, in _parse_args
    yr,mo,dy,hr,mn,sc,tz=self._parse(arg, datefmt)
  File "/usr/lib/zope2/lib/python/DateTime/DateTime.py", line 1087, in _parse
    raise SyntaxError, st
DateTime.SyntaxError: Wed, 14 Mar 2007 09:44:06 CDT
>>> dt = DateTime('Wed, 14 Mar 2007 09:44:06 CST')
>>> print dt.timezone()
US/Central

The results are the same for Mountain and pacific time as well.

I have not yet found a fix for this problem. I discovered it using PloneFeedFeeder when trying to parse a news feed with the datetime stamp used in this example.

Tags: bug zope
Revision history for this message
Andreas Jung (ajung) wrote :

Changes: submitter email, importance (critical => medium), new comment

This is not critical

Revision history for this message
Reed O'Brien (reedobrien) wrote :

I added entries
'edt':'US/Eastern', etc...
to the to the _zmap dict.

It appears that DST is calculated via time.daylight so mapping xDT to US/<zone> should be fine. I think;) Or I am an hour off.

Revision history for this message
Russ Ferriday (russf) wrote :

I'm working around this by wrapping calls to DateTime(str) in my app, since I think changes in DateTime may take a while:

affects: zope2 → datetime
Revision history for this message
Jens Vagelpohl (dataflake-deactivatedaccount-deactivatedaccount) wrote :

"EDT" actually does work in the latest DateTime code, but not CDT, MDT, PDT and other DST zone names.

Changed in datetime:
status: New → Confirmed
Revision history for this message
Lennart Regebro (regebro-gmail) wrote :

It should be noted that three character time zones are not unique. You should avoid them.

Revision history for this message
Colin Watson (cjwatson) wrote :

The datetime project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/datetime.

Changed in datetime:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.