Source code for timApp.util.flask.filters
from datetime import datetime, timedelta
import humanize
from markupsafe import soft_str
[docs]def map_format(value, pattern):
"""Applies Python string formatting on an object:
.. sourcecode:: jinja
{{ "%s - %s"|format("Hello?", "Foo!") }}
gives::
Hello? - Foo!
"""
return soft_str(pattern) % value
[docs]def humanize_datetime(value: datetime):
return humanize.naturaltime(value.replace(tzinfo=None))