scrapinghub / scrapinghub/dateparser
1st - 12th treated as months rather than days
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
Using the common date abbreviations of Date + st, nd, rd, th alone returns months for 1st - 12th rather than days.
Example of current behavior (desired) with 13th - 31st
dateparser.parse("13th")
dateparser.parse("25th 5pm")
> 2023-01-13 00:00:00
> 2023-01-25 17:00:00
Example of current behavior (unwanted) with 1st - 12th
dateparser.parse("2nd 9pm")
dateparser.parse("12th 11am")
> 2023-02-09 21:00:00
> 2023-12-09 11:00:00
Example of desired behavior with 1st - 12th
dateparser.parse("2nd 9pm")
dateparser.parse("12th 11am")
> 2023-01-02 21:00:00
> 2023-01-12 11:00:00
I'm aware this may be avoided by passing a DATE_ORDER option through the settings, but that would break other functionality when the default order of MDY is desired. And the use of the date abbreviations specified above are very common even with MDY, so some sort of solution to allow both would be ideal.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue through the dateparser.parse entry point with the examples in the report, then trace how ordinal suffixes are interpreted under the default MDY setting. Done means inputs such as "2nd 9pm" and "12th 11am" produce January 2 and January 12 while the existing 13th–31st behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100