scrapinghub / scrapinghub/dateparser
Improved relative parsing for dates
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
Would like to see more improved relative date parsing for things like "first day of next week" or "3rd Friday of next month". I tried a few combos, but it doesn't seem like what does get returned isn't correct or is nothing. Still learning and trying to understand the settings, etc.
# Date these commands were tried
>>> datetime.now()
datetime.datetime(2021, 1, 29, 12, 11, 5, 767319)
# Should be 2021/2/1
>>> dateparser.parse("1st day of next month")
datetime.datetime(2021, 3, 1, 11, 45, 25, 946280)
>>> dateparser.parse("1st day of next month", settings={"PARSERS": ["relative-time"], "PREFER_DATES_FROM": "future"})
datetime.datetime(2021, 3, 1, 12, 9, 46, 215356)
# Might be a bit ambiguous but probably should've been 2021/1/1
>>> dateparser.parse("1st day of month")
datetime.datetime(2021, 1, 28, 11, 46, 7, 6558)
>>> dateparser.parse("1st day of month", settings={"PARSERS": ["relative-time"], "PREFER_DATES_FROM": "future"})
datetime.datetime(2021, 1, 30, 12, 10, 26, 52697)
# Should be 2021/2/1
>>> dateparser.parse("1st day of next week")
datetime.datetime(2021, 2, 6, 12, 7, 0, 768280)
>>> dateparser.parse("1st day of next week", settings={"PARSERS": ["relative-time"], "PREFER_DATES_FROM": "future"})
datetime.datetime(2021, 2, 6, 12, 10, 48, 262064)
# Should be 2021/2/5
>>> dateparser.parse("1st Friday of next month")
>>> dateparser.parse("1st Friday of next month", settings={"PARSERS": ["relative-time"], "PREFER_DATES_FROM": "future"})
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 with the dateparser.parse examples in the issue and reproduce the reported results for relative phrases such as "1st day of next month" and "1st Friday of next month". Trace the relative parsing path and add coverage for the stated expected dates; done means these phrases return the dates described in the report without breaking the shown settings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100