akoumjian / datefinder

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

Detects datetime.datetime(2015, 12, 18, 0, 0) when given " 2015 " #197

Open Uettwillera opened 8 months ago

Uettwillera commented 8 months ago

When sending " 2015 " it returns December 18th, 2015.

> [x for x in datefinder.find_dates(" 2015 ")]
[datetime.datetime(2015, 12, 18, 0, 0)]
Uettwillera commented 8 months ago

Similar issue with any number really:

[x for x in datefinder.find_dates(" 7 ")] returns December 7th, 2023

whywouldyoumakemechooseausername commented 5 months ago

datefinder.find_dates() uses dateutil.parser.parse(), which returns a base date (by default: the current date), overwritten with parsed information.

Default output will always be data you provided + the current date (unless specified otherwise). This is undocumented behaviour, the base_date parameter for datefinder.find_dates(), which can be used to overwrite the base_date, however, is.

It may be a good idea to add not only the type of object it returns, but also a few words about its specific contents within the documentation.