scrapinghub / scrapinghub/dateparser
Timezone parser fails on hyphen-like characters
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
When hyphen-like characters are passed the parser ignores them, producing an incorrect output. An example of this in the wild would be on wikipedia, such as https://en.wikipedia.org/wiki/List_of_UTC_offsets, which uses the “−” U+2212 Minus Sign Unicode Character.
example = dateparser.parse("jan 15th UTC−06:00")
tzname = example.tzname()
> 2023-01-15 06:00:00+00:00
> UTC
I believe updating the regex to handle some or all of the "Unicode Dash Characters" under figure 6-3 at http://www.unicode.org/versions/latest/ch06.pdf would be quite beneficial. This table is available online on various websites as well if you'd rather not download the file.
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 locating the timezone parsing regex and reproduce the provided dateparser.parse example with U+2212. Done means hyphen-like Unicode characters in UTC offsets are recognized and the parsed result has the expected offset and timezone name.
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
- 48/100