Jonas Havelka
3 months ago
5 changed files with 0 additions and 20 deletions
@ -1,19 +0,0 @@ |
|||||
from django import template |
|
||||
from django.utils.safestring import mark_safe |
|
||||
from datetime import datetime, timedelta |
|
||||
from mamweb.settings import TIME_ZONE |
|
||||
import logging |
|
||||
register = template.Library() |
|
||||
|
|
||||
logger = logging.getLogger(__name__) |
|
||||
|
|
||||
@register.filter(name='kratke_datum', expects_localtime=True) |
|
||||
def kratke_datum(dt): |
|
||||
# None dává None, ne-datum dává False, aby se daly použít filtry typu "default". |
|
||||
if dt is None: |
|
||||
return None |
|
||||
if not isinstance(dt, datetime): |
|
||||
logger.warning(f"Špatné volání filtru {__name__}: {dt}") |
|
||||
return False |
|
||||
out = f'<time datetime="{dt.isoformat()}" title="{dt.strftime("%d. %m. %Y %H:%M")}">{dt.day}.{dt.month}.<span style="text-decoration:overline">{dt.year%100}</time>' |
|
||||
return mark_safe(out) |
|
Loading…
Reference in new issue