v0.8.9: Format email timestamps as 'Tuesday, August 8, 2026 @ 9:24pm' in America/Regina timezone

Add regina_dt Jinja2 template filter that converts UTC ISO-8601 timestamps
to America/Regina timezone and formats them as 'Weekday, Month D, YYYY @ H:MMam/pm'.
Applied to preview_sent_at and delivery_sent_at on the admin request page.
This commit is contained in:
Troll (Hermes Agent) 2026-08-12 03:53:37 +00:00
parent 9575464be2
commit d4f54bcff5
4 changed files with 23 additions and 4 deletions

19
app.py
View file

@ -91,6 +91,25 @@ from helpers import (
app = Flask(__name__)
app.config.from_object(Config)
# Template filter: format UTC ISO timestamp as "Tuesday, August 8, 2026 @ 9:24pm" in America/Regina.
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
_REGINA_TZ = ZoneInfo("America/Regina")
@app.template_filter("regina_dt")
def regina_dt_filter(value):
if not value:
return ""
try:
dt = datetime.fromisoformat(value)
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
dt = dt.astimezone(_REGINA_TZ)
return dt.strftime("%A, %B %-d, %Y @ %-I:%M%p").replace("AM", "am").replace("PM", "pm")
except (ValueError, TypeError):
return value
# Global request rate limiting by remote IP (default 60/min). The public form is further limited to 5/min.
limiter = Limiter(get_remote_address, app=app, default_limits=["60 per minute"])