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 timdate(value: datetime): return value.isoformat()
[docs]def humanize_timedelta(value: timedelta): return humanize.naturaldelta(value)
[docs]def humanize_datetime(value: datetime): return humanize.naturaltime(value.replace(tzinfo=None))