scrapinghub / scrapinghub/dateparser
Parser result wrong for weird input string
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
I'm currently trying to parse this string: '23.18.05'
My expectation would be that results are only valid for a setting like DATE_ORDER': 'YDM' and especially never try to parse the middle number as a year whatsoever.
It actually turns out, that you receive the following return-value with dateparser.parse: datetime.datetime(2018, 5, 23, 0, 0)
and this value with get_date_data:
{'date_obj': datetime.datetime(2018, 5, 23, 0, 0), 'period': 'day', 'locale': 'it'}
(I do not think that my locale setting changes the outcome here. If any more information is needed, comments would be much appreciated.)
I would actually expect to get "None" as a result with such a string when no settings are given, especially as there are no existing date formats, where the year is found in the middle. Maybe I'm actually using it wrong, but I think not.
Also as a little backstory (not really related to the issue) I am actually trying to parse a date off of receipts and this string was found as a possible date by my RegEx, as it was given as current time on the receipt. I could not find any documentation information about ignoring such types of strings yet, as the standard datetime-parser and dateutil-parser also do not throw any errors with such a string here.
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 reported input, '23.18.05', through dateparser.parse and get_date_data with default settings, then inspect the parser path that interprets the middle number as a year. Done means the default behavior matches the expected result and regression coverage verifies the handling of this string.
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
- 42/100