akoumjian / datefinder

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

Wrong date returned #95

Open chrobakos opened 6 years ago

chrobakos commented 6 years ago

Hi,

I've tried to run following code `import datefinder import datetime matches = datefinder.find_dates("the date is 1.4.2016 and so on")

for match in matches: print (match)`

and the result I'm getting is 2016-09-25 00:00:00

🤷

alexantao commented 5 years ago

I'm also getting wrong results. I have a bunch of files (photos taken), take their names and try to guess the date on their names. Some of then I got this:

File: testeimagem/01-07-2012_2a_Corrida_de_5_km_da_ASBAC_272310.jpg Date Found: 2019-09-05 00:00:00 But should be: 2012-07-01 (YYYY/MM/DD)

Another wrong results I get:

File: testeimagem/Captura de tela de 2017-06-26 14-37-17.png Date Found: 2017-06-26 14:00:00-17:00

This time it ignored the 37 minutes and considered 17 seconds as timezone.

Finally, I got an exception in this case: testeimagem/Captura de tela de 2017-11-27 13-04-28.png

Almost shure that's related to the same mistake as the previous, related to timezone. I think it is considering that the 28 is the timezone and raises an exception with the message:

ValueError: offset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24).