Skip to content

[pull] master from scrapinghub:master#94

Merged
pull[bot] merged 1 commit into
zanachka:masterfrom
scrapinghub:master
Jun 26, 2026
Merged

[pull] master from scrapinghub:master#94
pull[bot] merged 1 commit into
zanachka:masterfrom
scrapinghub:master

Conversation

@pull

@pull pull Bot commented Jun 26, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

…h_formats (#1345)

When a user-supplied date format contained %j (day of year), parse_with_formats
incorrectly treated the parsed date as having no month and no day. This caused
it to overwrite the correctly-parsed month and day with the current-date defaults
instead of preserving what strptime extracted.

Root cause: missing_day was computed as '"%d" not in date_format', missing %j
(and %-j) as day-of-year directives. A successful strptime with %j always
populates both the day and month fields (e.g. day 100 of 2023 = April 10).
The pre-existing _get_missing_parts helper already listed %j in the day
directive mapping but not in month.

Fix: add %j and %-j to the month directive mapping in _get_missing_parts, and
replace the ad-hoc missing_month/missing_day checks in parse_with_formats with
_get_missing_parts, which is the authoritative source for this logic.

Before:
  dateparser.parse("2023-100", date_formats=["%Y-%j"])
  -> datetime(2023, 6, 25)  # wrong: June 25 = today

After:
  dateparser.parse("2023-100", date_formats=["%Y-%j"])
  -> datetime(2023, 4, 10)  # correct: day 100 of 2023
@pull pull Bot locked and limited conversation to collaborators Jun 26, 2026
@pull pull Bot added the ⤵️ pull label Jun 26, 2026
@pull pull Bot merged commit 273eb23 into zanachka:master Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant