scrapinghub / dateparser

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

Add a way to tell if date is considered ambiguous #1099

Open slykar opened 2 years ago

slykar commented 2 years ago

I have a use-case where I want to inform the user that some date string is ambiguous. It would be great if DateDataParser could expose this as an additional property on DateData.

from dateparser.date import DateDataParser

parser = DateDataParser()
parser.get_date_data('11.12.13') 

# as a result
DateData(date_obj=datetime.datetime(2013, 11, 12, 0, 0), period='day', locale='en', ambiguous=True)

Knowing the date order used would be helpful too (as proposed in #733).

I'm not sure if the ambiguous property makes sense if we know or assume any locale? Maybe it should be set only if PREFER_LOCALE_DATE_ORDER: False.