Skip to content

TypeError when using timezone-aware as RELATIVE_BASE #491

Closed

Description

@perrinjerome

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

Activity

  1. noviluni commented on Jul 1, 2020

    @noviluni
    Contributor

    Added a comment in this related issue: #679 linking to a draft PR with a possible workaround.

  2. added a commit that references this issue on Oct 3, 2021
  3. added a commit that references this issue on Oct 29, 2021
  4. AdrianAtZyte commented on Sep 29, 2026

    @AdrianAtZyte
    Member

    Fixed in #881, released in dateparser 1.1.0 (2021-10-04).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions