Skip to content

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

@amineKammah

Description

@amineKammah

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions