Repository navigation
Reject a number displaced from a date with nowhere else to go - #1402
AdrianAtZyte wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
serhii73
left a comment
There was a problem hiding this comment.
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.
Fixes #1264