akoumjian / datefinder

Find dates inside text using Python and get back datetime objects
http://datefinder.readthedocs.org/en/latest/
MIT License
635 stars 167 forks source link

Incorrect Dates extracted #144

Open daksh-2233 opened 3 years ago

daksh-2233 commented 3 years ago

Is there a way to specify particular date format (eg dd-mm-yyyy) The date format in the text given is dd-mm-yyyy, but dates are extracted incorrectly

Ex: datefinder.find_dates('12.02.1980 ') Expected Output: 12.02.1980

Actual output: 02.12.1980

Also, what is the purpose of base_date argument ?

akoumjian commented 3 years ago

If you know your dates are day first, pass the argument first="day" to the method.

datefinder.find_dates('12.02.1980', first='day')

https://github.com/akoumjian/datefinder/blob/master/datefinder/__init__.py#L305

daksh-2233 commented 3 years ago

Hi @akoumjian , I tried passing the argument but it shows error :

File "date_test.py", line 2, in dates = datefinder.find_dates('12.02.2018',first="day") TypeError: find_dates() got an unexpected keyword argument 'first'

amzar96 commented 3 years ago

Hi @akoumjian , I tried passing the argument but it shows error :

File "date_test.py", line 2, in dates = datefinder.find_dates('12.02.2018',first="day") TypeError: find_dates() got an unexpected keyword argument 'first'

I also received the same error :(