diff options
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 3a349c04b..80d5af9d6 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -27,6 +27,7 @@ import hashlib from importlib import import_module import io from jinja2 import Template +import locale import os import random import re @@ -2111,6 +2112,18 @@ def get_image_path(instance, filename): return instance._get_image_path(filename) +def human_date(value): + language_code = settings.LANGUAGE_CODE.split("-") + language_code = language_code[0] + "_" + language_code[1].upper() + for language_suffix in (".utf8", ""): + try: + locale.setlocale(locale.LC_TIME, language_code + language_suffix) + break + except locale.Error: + pass + return value.strftime(settings.DATE_FORMAT) + + class IshtarFileSystemStorage(FileSystemStorage): def exists(self, name): path_name = self.path(name) |