scrapinghub / dateparser

python parser for human readable dates
BSD 3-Clause "New" or "Revised" License
2.5k stars 466 forks source link

Critical Bug: search_dates doesn't understand 7am (but ok with 7pm) #1221

Closed kamaca closed 4 months ago

kamaca commented 4 months ago

Folks, we need to address this ASAP. When using search_dates with something like "7am" it fails to understand the time correctly. It only happens to AM, while PM looks like ok Here is what I'm observing:

$ date
Thu Feb 22 20:14:33 PST 2024

$ pip3 show dateparser
Name: dateparser
Version: 1.2.0
. . . . .
>>> from dateparser.search import search_dates

>>> search_dates("there is something tomorrow at 7am")
[('tomorrow at 7am', datetime.datetime(2024, 2, 23, 20, 15, 47, 376532))]

>>> search_dates("there is something tomorrow at 7pm")
[('tomorrow at 7pm', datetime.datetime(2024, 2, 23, 19, 0))]

>>> search_dates("there is something tomorrow at 7:00am")
[('tomorrow at 7:00am', datetime.datetime(2024, 2, 23, 7, 0))]

>>>

When adding :00 to it looks like does the trick, however the text doesn't always have hr:min format
so the issue is why it fails with AM?

search_dates("there is something tomorrow at 7am") [('tomorrow at 7am', datetime.datetime(2024, 2, 23, 20, 15, 47, 376532))]

Please help with this issue. Thanks for your help and support!

Gallaecio commented 4 months ago

https://github.com/scrapinghub/dateparser/issues/1037