diff --git a/app/main.py b/app/main.py index 43ca1c5..eff7ae4 100644 --- a/app/main.py +++ b/app/main.py @@ -1,4 +1,5 @@ import json +from datetime import datetime, timezone from pathlib import Path from fastapi import Depends, FastAPI, Form, Request @@ -26,6 +27,18 @@ templates.env.globals.update( ) +def format_datum(value: datetime | None) -> str: + """Formatiere einen UTC-Zeitstempel als lokale Datums-/Zeitangabe.""" + if not value: + return "" + if value.tzinfo is None: + value = value.replace(tzinfo=timezone.utc) + return value.astimezone().strftime("%d.%m.%Y, %H:%M") + + +templates.env.filters["datum"] = format_datum + + # --------------------------------------------------------------------------- # Hilfsfunktionen # --------------------------------------------------------------------------- diff --git a/app/templates/_link_card.html b/app/templates/_link_card.html index 9848a40..cb0829c 100644 --- a/app/templates/_link_card.html +++ b/app/templates/_link_card.html @@ -6,6 +6,9 @@
{{ link.url }}
+
+ 🕓 hinzugefügt am {{ link.created_at | datum }} +