Skip to content
Snippets Groups Projects
Commit f75b160d authored by Martin Mareš's avatar Martin Mareš
Browse files

util_format: Zkrácená podoba timestampu

parent d5c26c39
No related branches found
No related tags found
1 merge request!86Registrace
......@@ -41,6 +41,13 @@ def timeformat(dt: datetime) -> str:
return dt.astimezone().strftime("%Y-%m-%d %H:%M")
def timeformat_short(dt: datetime) -> str:
if dt is None:
return ''
else:
return dt.astimezone().strftime("%Y-%m-%d")
def timedelta(d: datetime, ref: Optional[datetime] = None, descriptive: bool = False) -> str:
"""Vyrábí česky formátované řetězece 'za 3 minuty', 'před 27 dny' a podobně
z rozdílu daného datetime a referenčního času (například now).
......
......@@ -24,6 +24,7 @@ app.jinja_env.trim_blocks = True
# Filtry definované v mo.util_format
app.jinja_env.filters.update(timeformat=util_format.timeformat)
app.jinja_env.filters.update(timeformat_short=util_format.timeformat_short)
app.jinja_env.filters.update(inflected=util_format.inflect_number)
app.jinja_env.filters.update(inflected_by=util_format.inflect_by_number)
app.jinja_env.filters.update(timedelta=util_format.timedelta)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment