summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2016-06-03 23:02:53 -0500
committermarc <a01200356@itesm.mx>2016-08-05 23:51:04 -0500
commita4c77f88d0ca52b9c236c95a16b2a527f811c0e6 (patch)
treed9724dde96832a303e5d94df591091ccbd1ceaaf /searx
parent93ef11adc0c4653c8fadd4b4dc7c38a74f4cdbd6 (diff)
downloadsearxng-a4c77f88d0ca52b9c236c95a16b2a527f811c0e6.tar.gz
searxng-a4c77f88d0ca52b9c236c95a16b2a527f811c0e6.zip
[fix] exception if locale doesn't have a date format
occitan, for example
Diffstat (limited to 'searx')
-rw-r--r--searx/utils.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/searx/utils.py b/searx/utils.py
index c027bff20..aa8ce92a1 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -206,7 +206,13 @@ def format_date_by_locale(date, locale_string):
if locale_string == 'all':
locale_string = settings['ui']['default_locale'] or 'en_US'
- return format_date(date, locale=locale_string)
+ # to avoid crashing if locale is not supported by babel
+ try:
+ formatted_date = format_date(date, locale=locale_string)
+ except:
+ formatted_date = format_date(date, "YYYY-MM-dd")
+
+ return formatted_date
def dict_subset(d, properties):