dateparser icon indicating copy to clipboard operation
dateparser copied to clipboard

Parsing using `{"PREFER_DAY_OF_MONTH": "last", "PREFER_MONTH_OF_YEAR": "last"}` doesn't use last day of the last month

Open amineKammah opened this issue 1 year ago • 0 comments

Hi, I noticed that when parsing a date with missing month and day of month with {"PREFER_DAY_OF_MONTH": "last", "PREFER_MONTH_OF_YEAR": "last"} settings, we default to the last day of the current month instead of the last day of the last month.

For example, when running this code in February, it will return 2022/12/28 instead of 2022/12/31, as the last day of feb is 28.

>>> import dateparser
>>> dateparser.parse("2022", settings={"PREFER_DAY_OF_MONTH": "last", "PREFER_MONTH_OF_YEAR": "last"})
datetime.datetime(2022, 12, 28, 0, 0)

amineKammah avatar Feb 01 '24 14:02 amineKammah