Inconsistent parsing of German dates

Bug #974206 reported by Jonas H
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
Confirmed
High
Tomi Hukkalainen

Bug Description

Hey Gustavo :-)

German dates (DD.MM.YYYY) are parsed inconsistently:

>>> parse('20.2.2000') # 20th Feb
datetime.datetime(2000, 2, 20, 0, 0) # 20th Feb

>>> parse('1.2.2000') # 1st Feb
datetime.datetime(2000, 1, 2, 0, 0) # 2nd Jan

The result of parse() should either always follow the first scheme or always follow the second scheme to avoid surprises.

Revision history for this message
Tomi Hukkalainen (tpievila) wrote : Re: [Bug 974206] [NEW] Inconsistent parsing of German dates

  status confirmed

  importance high

  assignee tpievila

--
Tomi Pieviläinen, +358 400 487 504
A: Because it disrupts the natural way of thinking.
Q: Why is top posting frowned upon?

Changed in dateutil:
assignee: nobody → Tomi Pieviläinen (tpievila)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Andreas Hilboll (andreas-h) wrote :

couldn't the chosen scheme depend on locale settings? for german locale, use first scheme, and for other locales, other?

Revision history for this message
Dave McKee (dave-mckee) wrote :

Pass dayfirst=True to the parser:

>>> dateutil.parser.parse("20.2.2000")
datetime.datetime(2000, 2, 20, 0, 0)
>>> dateutil.parser.parse("20.2.2000", dayfirst=True)
datetime.datetime(2000, 2, 20, 0, 0)
>>> dateutil.parser.parse("1.2.2000")
datetime.datetime(2000, 1, 2, 0, 0)
>>> dateutil.parser.parse("1.2.2000", dayfirst=True)
datetime.datetime(2000, 2, 1, 0, 0)

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.