scrapinghub / scrapinghub/dateparser

Prepositions with turn of year ignore turn of year

Open
#1,295 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
520
Avg merge
22h 56m
Merged PRs (30d)
6

Description

If the seach_dates finds two dates "from … until", the turn of year is not recognized.

Expected

"Closed from December 23th until January 7th" to be parsed into
(today.year, 12, 23, 0, 0) and (today.year+1, 1, 8, 0, 0).

Wish

Even better would be if the year would depend on the distance to today:
Aforementioned string would parse into

  • last-year, this-year if today is "near" January 7th.
  • this-year, next-year if today is "near" December 23th
Test case
    def test_search_dates_with_prepositions_with_turn_of_year(self):
        """Test `search_dates` for parsing English date ranges with
        prepositions, turn of year and language detection.
        """
        result = search_dates(
            "Closed from 23th December until 8th January.",
            add_detected_language=True,
            languages=["en"],
        )
        expected = [
            ("23th December", datetime.datetime(today.year, 12, 23, 0, 0), "en"),
            ("8th January", datetime.datetime(today.year+1, 1, 8, 0, 0), "en"),
        ]
        assert result == expected

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 existing search_dates implementation and the supplied test case, test_search_dates_with_prepositions_with_turn_of_year. Reproduce the issue with the English date range, then make the result match the expected two dates across the December–January year boundary, including detected language.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.