Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change is a narrowly scoped English-only simplification with strong regression/control test coverage and consistent regenerated data updates.
Pull request overview
This PR fixes English parsing for ordinal dates that include the phrase “day of” (e.g., the 1st day of March, 2025) by adding an English translation simplification that rewrites "<ordinal> day of" into the already-supported "<ordinal> of" form, while ensuring “day” continues to work as a relative-time unit.
Changes:
- Add an English simplification rule to convert
(\d{1,2}(st|nd|rd|th)) day of→\1 ofin supplementary YAML and regenerateden.pydata. - Add parameterized tests covering ordinal suffixes, casing/whitespace/time, and controls to ensure existing interpretations and relative-day parsing remain unchanged.
- Update README with the newly supported example.
File summaries
| File | Description |
|---|---|
tests/test_date_parser.py |
Adds regression + control tests for “ day of …” parsing and ensures relative-day behavior remains intact. |
README.rst |
Documents the new supported input example for the public API. |
dateparser/data/date_translation_data/en.py |
Regenerated English translation data including the new simplification rule. |
dateparser_data/supplementary_language_data/date_translation_data/en.yaml |
Source YAML change introducing the new simplification rule. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
AdrianAtZyte
left a comment
There was a problem hiding this comment.
LGTM, thanks! Two optional nits: I would drop the README example, since the list there is for broad features and this is a fairly niche phrasing, and I think the new tests could be trimmed to three or four cases, since relative days are already covered elsewhere and the whitespace/case variants exercise the simplification machinery rather than this change.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1383 +/- ##
=======================================
Coverage 97.18% 97.18%
=======================================
Files 236 236
Lines 3057 3057
=======================================
Hits 2971 2971
Misses 86 86 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks, that makes sense. I've removed the README example and trimmed the new tests to four cases, one for each ordinal suffix. The full test suite still passes. |
Dates like
the 1st day of March, 2025currently returnNone, even though the same date withoutdayparses correctly. This adds a small English rule that treats1st day oflike1st of, so the existing date parser can handle it.The change updates the English language data and its generated file, with four regression cases covering
st,nd,rd, andth.The full suite passes on Python 3.12: 24,363 passed, 3 skipped, and 1 expected failure. Generated-data consistency, lint, and formatting checks pass too.
Fixes #1171, fixes #1256.