comparison libervia/web/pages/_browser/template.py @ 1529:de7e468e2d44

browser (template): fix use of `auto*` in `date_fmt`
author Goffi <goffi@goffi.org>
date Thu, 08 Jun 2023 23:32:46 +0200
parents eb00d593801d
children 285c49d7aad3
comparison
equal deleted inserted replaced
1528:66c1a90da1bc 1529:de7e468e2d44
38 def current(self, value): 38 def current(self, value):
39 return self._indexes.get(value) 39 return self._indexes.get(value)
40 40
41 41
42 gidx = Indexer() 42 gidx = Indexer()
43 # suffix use to avoid collision with IDs generated in static page 43 # suffix used to avoid collision with IDs generated in static page
44 SCRIPT_SUFF = "__script__" 44 SCRIPT_SUFF = "__script__"
45 45
46 def escape_html(txt): 46 def escape_html(txt):
47 return ( 47 return (
48 txt 48 txt
161 fmt, auto_limit, auto_old_fmt, auto_new_fmt = "auto", 0, "short", "HH:mm" 161 fmt, auto_limit, auto_old_fmt, auto_new_fmt = "auto", 0, "short", "HH:mm"
162 if fmt == "auto": 162 if fmt == "auto":
163 limit = moment().startOf('day').subtract(auto_limit, 'days') 163 limit = moment().startOf('day').subtract(auto_limit, 'days')
164 m_fmt = auto_old_fmt if date < limit else auto_new_fmt 164 m_fmt = auto_old_fmt if date < limit else auto_new_fmt
165 165
166 if fmt == "short": 166 elif fmt == "short":
167 m_fmt = "DD/MM/YY" if date_only else "DD/MM/YY HH:mm" 167 m_fmt = "DD/MM/YY" if date_only else "DD/MM/YY HH:mm"
168 elif fmt == "medium": 168 elif fmt == "medium":
169 m_fmt = "ll" if date_only else "lll" 169 m_fmt = "ll" if date_only else "lll"
170 elif fmt == "long": 170 elif fmt == "long":
171 m_fmt = "LL" if date_only else "LLL" 171 m_fmt = "LL" if date_only else "LLL"