scrapinghub / scrapinghub/dateparser

Incorrect date returned when input string contains only number and letter "S"

Open
#1,133 1 comment 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

When using the dateparser library with the following code:

from dateparser.search import search_dates

settings = {'REQUIRE_PARTS': ['month', 'year']}
parsed = search_dates('1324 S',
                      languages=['en'],
                      settings=settings)
print(parsed)

The output is:

[('1324 S', {todays date})]

which is incorrect as the input string does not contain a recognizable date. This issue occurs when the input string contains only a number followed by a blank space and the letter "S".

Steps to Reproduce:

  1. Run the code above with the input string '1324 S'
  2. Observe the output, which will be in the format [('1324 S', {todays date})]
  3. Try it using any number followed by ' S'

Expected Result:
The dateparser library should return an empty list or an error, as the input string does not contain a recognizable date.

Actual Result:
The dateparser library returns today's date, incorrectly treating the input string as a valid date.

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 by running the reported search_dates example with the input "1324 S" and nearby numeric variants, then trace how the parser handles the number and trailing letter. Add a regression test for this input and verify that search_dates returns an empty list or an error rather than today's date.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.