Mercurial > libervia-backend
comparison sat/tools/common/template.py @ 2907:8ca12f30f61f
template (filters): set locale when using "date_fmt"
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Apr 2019 08:21:51 +0200 |
parents | 7dbdbd132649 |
children | d8857e913309 |
comparison
equal
deleted
inserted
replaced
2906:7dbdbd132649 | 2907:8ca12f30f61f |
---|---|
644 def _cur_gidx(self, ctx, value): | 644 def _cur_gidx(self, ctx, value): |
645 """Use current current global index as suffix""" | 645 """Use current current global index as suffix""" |
646 current = ctx["gidx"].current(value) | 646 current = ctx["gidx"].current(value) |
647 return value if not current else u"{}_{}".format(value, current) | 647 return value if not current else u"{}_{}".format(value, current) |
648 | 648 |
649 def _date_fmt( | 649 def _date_fmt(self, timestamp, fmt="short", date_only=False, auto_limit=None, |
650 self, timestamp, fmt="short", date_only=False, auto_limit=None, auto_old_fmt=None | 650 auto_old_fmt=None): |
651 ): | |
652 if is_undefined(fmt): | 651 if is_undefined(fmt): |
653 fmt = u"short" | 652 fmt = u"short" |
654 | |
655 try: | 653 try: |
656 return date_utils.date_fmt( | 654 return date_utils.date_fmt( |
657 timestamp, fmt, date_only, auto_limit, auto_old_fmt | 655 timestamp, fmt, date_only, auto_limit, auto_old_fmt, |
656 locale_str = self._locale_str | |
658 ) | 657 ) |
659 except Exception as e: | 658 except Exception as e: |
660 log.warning(_(u"Can't parse date: {msg}").format(msg=e)) | 659 log.warning(_(u"Can't parse date: {msg}").format(msg=e)) |
661 return timestamp | 660 return timestamp |
662 | 661 |