scrapinghub / scrapinghub/dateparser
ISO 8601 YYYY-MM-DD parsing depends on locale
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
An ISO 8601 with dashes YYYY-MM-DD is quite common and I would think that there isn't much chance to confuse with other formats. However, the parsing depends on the locale leading to incorrectly parsed dates. Examples:
>>> dateparser.parse('1991-05-11')
datetime.datetime(1991, 5, 11, 0, 0) # correct
>>> dateparser.parse('1991-05-11', locales=["en"])
datetime.datetime(1991, 5, 11, 0, 0) # correct
>>> dateparser.parse('1991-05-11', locales=["de"])
datetime.datetime(1991, 11, 5, 0, 0) # wrong!
>>> dateparser.parse('1991-05-11', locales=["es"])
datetime.datetime(1991, 11, 5, 0, 0) # wrong!
>>> print(dateparser.parse('1991-05-17', locales=["de"]))
None # wrong!
Is this the expected behavior, or is it just a bug?
Note that the input can be in many formats including ISO, which is why I want to give locales. But I do need ISO to work correctly.
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 dateparser.parse examples with locales=["de"] and locales=["es"], including both valid and invalid day values. Done means dashed ISO dates parse as YYYY-MM-DD regardless of the selected locale, while the issue's other locale-sensitive formats remain supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100