dateparser
dateparser copied to clipboard
TypeError when using timezone-aware as RELATIVE_BASE
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
Added a comment in this related issue: https://github.com/scrapinghub/dateparser/issues/679 linking to a draft PR with a possible workaround.