Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] exception if locale doesn't have a date format occitan, for example

marca4c77f88d0ca
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):