scrapinghub / dateparser

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

dateparser does not result consistently #514

Closed karthikshub closed 3 years ago

karthikshub commented 5 years ago

now-15m doesn't result consistent output.

stmp = dateparser.parse('now-15min') stmp datetime.datetime(2019, 4, 4, 9, 49, 23, 29148) stmp = dateparser.parse('now-15M') stmp datetime.datetime(2019, 4, 4, 9, 49, 37, 407403) stmp = dateparser.parse('now-15m') stmp datetime.datetime(2019, 4, 4, 9, 49, 49, 710735) stmp = dateparser.parse('now-15d') stmp datetime.datetime(2019, 3, 20, 10, 4, 57, 439242) stmp = dateparser.parse('now-15m') stmp datetime.datetime(2018, 1, 4, 10, 5, 3, 744759) dateparser.version '0.7.1'

Gallaecio commented 5 years ago

I can reproduce it as well.

rennerocha commented 5 years ago

Same root cause as #549 . Printing the content of this line, we can see that the locale used changed.

In [3]: dateparser.parse('now-15m') 
   ...:                                                                                                                                                                     
{'date_obj': datetime.datetime(2019, 9, 3, 15, 21, 32, 569534), 'period': 'day', 'locale': 'en'}
Out[3]: datetime.datetime(2019, 9, 3, 15, 21, 32, 569534)

In [4]: dateparser.parse('now-15d') 
   ...:                                                                                                                                                                     
{'date_obj': datetime.datetime(2019, 8, 19, 15, 36, 36, 695301), 'period': 'day', 'locale': 'lb'}
Out[4]: datetime.datetime(2019, 8, 19, 15, 36, 36, 695301)

In [5]: dateparser.parse('now-15m') 
   ...:                                                                                                                                                                     
{'date_obj': datetime.datetime(2018, 6, 3, 15, 36, 40, 798523), 'period': 'month', 'locale': 'lb'}
Out[5]: datetime.datetime(2018, 6, 3, 15, 36, 40, 798523)
karthikshub commented 5 years ago

Thank you !

noviluni commented 3 years ago

This was fixed in the last version dateparser==1.0.0: https://github.com/scrapinghub/dateparser/pull/781

Thanks for the feedback :)