on master help sign in
[fix] exception if locale doesn't have a date format
a4c77f8marc
searx/utils.py+7−1
@@ -206,7 +206,13 @@ def format_date_by_locale(date, locale_string):
206 if locale_string == 'all':
206 if locale_string == 'all':
207 locale_string = settings['ui']['default_locale'] or 'en_US'
207 locale_string = settings['ui']['default_locale'] or 'en_US'
208
208
209+ # to avoid crashing if locale is not supported by babel
210+ try:
209− return format_date(date, locale=locale_string)
211+ formatted_date = format_date(date, locale=locale_string)
212+ except:
213+ formatted_date = format_date(date, "YYYY-MM-dd")
214+
215+ return formatted_date
210
216
211
217
212def dict_subset(d, properties):
218def dict_subset(d, properties):