Faulty behavior of "dayfirst" or another issue leading to wrong parsing
Title is unclear, since I don't know WHAT causes the issue. But "dayfirst=True" implies logically that month comes last in the string. But check this:
>>> parse("2020-1-10", dayfirst=True)
datetime.datetime(2020, 10, 1, 0, 0) #correct
>>> parse("2020-1-10", dayfirst=False)
datetime.datetime(2020, 1, 10, 0, 0) #correct
>>> parse("2020-09-30", dayfirst=True)
datetime.datetime(2020, 9, 30, 0, 0) #false, should give an error because month can't be bigger than 12
>>> parse("2020-09-30", dayfirst=False)
datetime.datetime(2020, 9, 30, 0, 0) #correct
parse("2020-30-09", dayfirst=True)
datetime.datetime(2020, 9, 30, 0, 0) #correct
>>> parse("2020-30-09", dayfirst=False)
dateutil.parser._parser.ParserError: month must be in 1..12: 2020-30-09 #That's the expected output
So, it looks like "something is wrong" when dayfirst=True. It could have been the range check that results in a parserError month must be in 1..12: does not happen, but:
>>> parse("2020-09-31", dayfirst=True)
dateutil.parser._parser.ParserError: day is out of range for month: 2020-09-31 #huh? what about dayfirst???
Yeah i have the same issue and it seems for some reason that everyone is fine with it.
From parser._parse docstring:
::param dayfirst
Whether to interpret the first value in an ambiguous 3-integer date (e.g. 01/05/09) as the day (True) or month (False).
If yearfirst is set to True, this distinguishes between YDM and YMD.
So seems like this parameter is not considered when providing a 4 character year, as in your examples.