Skip to content

Reject a number displaced from a date with nowhere else to go - #1402

Closed
AdrianAtZyte wants to merge 1 commit into
scrapinghub:masterfrom
AdrianAtZyte:displaced-number
Closed

AdrianAtZyte wants to merge 1 commit into
scrapinghub:masterfrom
AdrianAtZyte:displaced-number

Conversation

@AdrianAtZyte

Copy link
Copy Markdown
Member

Fixes #1264

@codspeed

codspeed Bot commented Sep 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing AdrianAtZyte:displaced-number (c7f07b2) with master (901414a)

Open in CodSpeed

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.21%. Comparing base (901414a) to head (c7f07b2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1402   +/-   ##
=======================================
  Coverage   97.21%   97.21%           
=======================================
  Files         236      236           
  Lines        3084     3086    +2     
=======================================
+ Hits         2998     3000    +2     
  Misses         86       86           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AdrianAtZyte
AdrianAtZyte marked this pull request as ready for review September 23, 2026 07:34

@serhii73 serhii73 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This fixes 6/4/25 0730, but the same displacement also happens in day ranges, where
master's silent drop of the extra number gave the right start date:

import dateparser
from dateparser.search import search_dates

dateparser.parse("June 12-14, 2021")                        # master: 2021-06-12  PR: None
dateparser.parse("Jun 12-14 2021")                          # master: 2021-06-12  PR: None
dateparser.parse("12.-14. Juni 2021", languages=["de"])     # master: 2021-06-12  PR: None
dateparser.parse("12.-14.06.2021", languages=["de"])        # master: 2021-06-12  PR: None
dateparser.parse("12-14 июня 2021", languages=["ru"])       # master: 2021-06-12  PR: None
dateparser.parse("12 - 14 czerwca 2021", languages=["pl"])  # master: 2021-06-12  PR: None

search_dates("The conference is June 12-14, 2021 in Boston.")
# master: [('June 12-14, 2021 in', datetime(2021, 6, 12, 0, 0))]
# PR:     [('June 12-14', datetime(2014, 6, 12, 0, 0)), ('2021 in', datetime(2021, 6, 12, 0, 0))]

In June 12-14, 2021, 14 is read as a two-digit year because the day is already taken. Then 2021
displaces it, the same pattern as 25 in 6/4/25 0730. Since ranges like these are very common on
event pages, could the check exempt a number that is the second half of a range (N-N, N.-N.,
N, N), or be limited to the shape from #1264 (a complete numeric d/m/y date followed by a
separate number)? Adding a few of the strings above as tests would keep this covered.

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.

Interpreting time

2 participants