"GMT+1" is parsed as "GMT-1"

Bug #1056186 reported by Lyse
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
New
Undecided
Unassigned

Bug Description

When parsing timezones such as "GMT+1" (GMT plus one) the result is "GMT-1" (GMT minus one) and vice verca. Replacing "GMT" string with "UTC" shows same behaviour. However just "+1" or "-1" as timezone information works as expected.

Both dateutil versions 1.5 and 2.0 are affected by this issue.

>>> import dateutil.parser
>>> dateutil.parser.parse("25. Sep. 2012 15:00:00 GMT+1")
datetime.datetime(2012, 9, 25, 15, 0, tzinfo=tzoffset(None, -3600))
# Parsed timezone offset should be +3600.

>>> dateutil.parser.parse("25. Sep. 2012 15:00:00 GMT-1")
datetime.datetime(2012, 9, 25, 15, 0, tzinfo=tzoffset(None, 3600))
# Parsed timezone offset should be -3600.

>>> dateutil.parser.parse("25. Sep. 2012 15:00:00 +1")
datetime.datetime(2012, 9, 25, 15, 0, tzinfo=tzoffset(None, 3600))
# Parsed timezone offset is correct.

Revision history for this message
Lennart Regebro (regebro-gmail) wrote :

Parsing GTM+1 this way is actually a part of the Posix specification. This is therefore a feature, and not a bug.

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.