dateparser icon indicating copy to clipboard operation
dateparser copied to clipboard

TypeError when using timezone-aware as RELATIVE_BASE

Open perrinjerome opened this issue 6 years ago • 1 comments

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

perrinjerome avatar Jan 22 '19 00:01 perrinjerome

Added a comment in this related issue: https://github.com/scrapinghub/dateparser/issues/679 linking to a draft PR with a possible workaround.

noviluni avatar Jul 01 '20 15:07 noviluni