Can someone tell me how I can parse a French date in Python? Sorry if the question is repeated, but I could not find it.
Here is what I tried using the dateutil parser:
import locale from dateutil.parser import parse as parse_dt locale.setlocale(locale.LC_TIME, 'fr_FR.UTF-8')
Edit: add some context:
I parse dates; I don’t know the format of my string in advance The idea is to analyze many dates on the fly:
parse_dt(u'Aujourd''hui ',fuzzy= True) parse_dt(u'Hier',fuzzy= True)
Edit using another library:
Using a library of parsedatims and some regular expression to translate French words, I can get the following:
import parsedatetime import re cal = parsedatetime.Calendar() cal.parse(re.sub('juil.*' ,'jul' ,'20 juillet')) ((2015, 7, 20, 10, 25, 47, 4, 283, 1), 1)
Perhaps I should generalize this to all the French months?
python date parsing internationalization localization
agstudy
source share