# HG changeset patch # User Goffi # Date 1680188021 -7200 # Node ID 73936abc68384069ceab95a2be68b9635571945c # Parent 432f7e422a270c93452daa3ca9143b3f92f37dbb tools (common/template): let specify timezone name in `date_fmt` filter diff -r 432f7e422a27 -r 73936abc6838 sat/tools/common/template.py --- 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))