Mercurial > libervia-backend
changeset 4030:73936abc6838
tools (common/template): let specify timezone name in `date_fmt` filter
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 30 Mar 2023 16:53:41 +0200 (20 months ago) |
parents | 432f7e422a27 |
children | a2d4bd1943ba |
files | sat/tools/common/template.py |
diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/tools/common/template.py Thu Mar 30 16:52:18 2023 +0200 +++ b/sat/tools/common/template.py Thu Mar 30 16:53:41 2023 +0200 @@ -761,14 +761,23 @@ current = ctx["gidx"].current(value) return value if not current else "{}_{}".format(value, current) - def _date_fmt(self, timestamp, fmt="short", date_only=False, auto_limit=7, - auto_old_fmt="short", auto_new_fmt="relative"): + def _date_fmt( + self, + timestamp: Union[int, float], + fmt: str = "short", + date_only: bool = False, + auto_limit: int = 7, + auto_old_fmt: str = "short", + auto_new_fmt: str = "relative", + tz_name: Optional[str] = None + ) -> str: if is_undefined(fmt): fmt = "short" try: return date_utils.date_fmt( timestamp, fmt, date_only, auto_limit, auto_old_fmt, - locale_str = self._locale_str + auto_new_fmt, locale_str = self._locale_str, + tz_info=tz_name or date_utils.TZ_UTC ) except Exception as e: log.warning(_("Can't parse date: {msg}").format(msg=e))