scrapinghub / scrapinghub/dateparser

Improved relative parsing for dates

Open
#871 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.