dateutil parser bug for years < 100

Bug #1158275 reported by Holger Joukl
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
Fix Released
Undecided
Unassigned

Bug Description

dateutil parser erroneously ignores significant leading year digits for 4-digit years < 100:

(Python 2.7.3)
>>> import datetime
>>> import dateutil
>>> import dateutil.parser
>>> dateutil.__version__
'1.5'
>>> dt = datetime.datetime(3, 2, 1)
>>> print dt.isoformat()
0003-02-01T00:00:00
>>> dateutil.parser.parse(dt.isoformat(), yearfirst=True, dayfirst=False)datetime.datetime(2003, 2, 1, 0, 0)
>>> dateutil.parser.parse(dt.isoformat(), yearfirst=True, dayfirst=False).isoformat()
'2003-02-01T00:00:00'
>>>
>>> dt = datetime.datetime(99, 2, 1)
>>> print dt.isoformat()
0099-02-01T00:00:00
>>> dateutil.parser.parse(dt.isoformat(), yearfirst=True, dayfirst=False).isoformat()
'1999-02-01T00:00:00'

Looks like the significant leading digits get ignored, triggering the 2-digit-year rules.

Years >= 100 work as expected:
>>> dt = datetime.datetime(100, 2, 1)
>>> dateutil.parser.parse(dt.isoformat(), yearfirst=True, dayfirst=False).isoformat()
'0100-02-01T00:00:00'
>>>

Revision history for this message
Holger Joukl (jholg) wrote :

A note for posterity: This has long(?) been fixed - modern dateutil versions (e.g. 2.8.1) do not suffer from this bug anymore.

(dateutil issue tracking has moved to GitHub years ago)

Changed in dateutil:
status: New → Fix Released
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.