diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-15 16:37:42 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:20:59 +0100 |
commit | e3ce9c77d36db4510076b677ec7ce1e0021a51f8 (patch) | |
tree | edb1258d180c35e73a10ab7120c69d81b3925d44 /ishtar_common/utils.py | |
parent | 905dfbb0ebb91af7b7acaae256306f178863c57f (diff) | |
download | Ishtar-e3ce9c77d36db4510076b677ec7ce1e0021a51f8.tar.bz2 Ishtar-e3ce9c77d36db4510076b677ec7ce1e0021a51f8.zip |
Syndication - serialization - display sheet operation
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) |