scrapinghub / scrapinghub/dateparser
TypeError when using timezone-aware as RELATIVE_BASE
Open
Nobody has claimed this yet.
Type: Bug
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
With this snippet:
# dateparser==0.7.0 ( also reproduces on master branch )
import dateparser
import datetime
import pytz
settings = { "RELATIVE_BASE": datetime.datetime.now().replace(tzinfo=pytz.timezone("Europe/Paris")) }
for input_ in ( "2009-06-01T10:00:00+09:00", "yesterday", "July 5th"):
print (input_, dateparser.parse(input_), dateparser.parse(input_, settings=settings))
"2009-06-01T10:00:00+09:00" or "yesterday" work as expected, but "July 5th" cause a TypeError: can't compare offset-naive and offset-aware datetimes, that is raised 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 with dateparser/parser.py at line 389 and run the supplied Python snippet against the current code. Trace how RELATIVE_BASE is handled for the ISO, relative, and month-name inputs, then verify that timezone-aware bases no longer produce the naive/aware datetime comparison error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100