Skip to content

Handling whitespace when matching relative dates #916

Open
@kss149

Description

@kss149

This is for version dateparser==1.0.0.
I've noticed that for some of the dates I tried to parse I need to add spaces to make parsing work and for some I need to remove them.
It seems a bit random and I am guessing it depends on how the string was added to date_translation_data.
That doesn't seem very flexible or reliable, and I wonder if it would make sense to either remove all whitespace from both input data and date_translation_data before matching, or make them optional.

Examples

  • 2 minutes ago in Mandarin
>>> dateparser.parse("2分鐘前")
>>> dateparser.parse("2 分鐘前")                  -> works only if you add space between the number and symbol
datetime.datetime(2021, 4, 28, 20, 45, 19, 266428)
  • 2 months ago in Thai
>>> dateparser.parse("2 เดือน ที่ผ่านมา")            -> doesn't work with space between months and ago
>>> dateparser.parse("2 เดือนที่ผ่านมา")             -> works when you remove space between months and ago
datetime.datetime(2021, 2, 28, 22, 3, 40, 264496)
>>> dateparser.parse("2เดือนที่ผ่านมา")              -> doesn't work when you remove all spaces

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug - LanguageSubtype of bug, related to language data

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions