Skip to content

fix: force month-day order for ISO leading year with explicit DATE_ORDER - #1378

Closed
3xp0rt wants to merge 1 commit into
scrapinghub:masterfrom
3xp0rt:fix
Closed

3xp0rt wants to merge 1 commit into
scrapinghub:masterfrom
3xp0rt:fix

Conversation

@3xp0rt

@3xp0rt 3xp0rt commented Sep 5, 2026

Copy link
Copy Markdown

dateparser already forced month-day ordering after a leading 4-digit year, but only when DATE_ORDER wasn't explicitly set. So an explicit DATE_ORDER=DMY/YDM (needed for a source's genuinely ambiguous dates) still broke unambiguous ISO strings:

dateparser.parse("2026-08-31", settings={"DATE_ORDER": "DMY"})  # -> None (invalid month=31)
dateparser.parse("2026-05-08", settings={"DATE_ORDER": "DMY"})  # -> 2026-08-05 (swapped, wrong)

This drops that guard, so a leading year always fixes the remaining order as month-then-day, regardless of DATE_ORDER. Ambiguous non-ISO strings without a leading year (e.g. "03-12-2026") still honor DATE_ORDER as before.

@AdrianAtZyte

Copy link
Copy Markdown
Member

Not sure about this one. If we really want to enforce DATE_ORDER with ISO, which may make no sense to begin with, should we not fail on 2026 as day?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants