frontend: date UTC convertite in ora italiana alla presentazione (#42)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Filtro local_dt: il backend parla UTC, la presentazione e' in Europe/Rome (#42)."""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def local_dt(flask_app):
|
||||
return flask_app.jinja_env.filters["local_dt"]
|
||||
|
||||
|
||||
def test_summer_time(local_dt):
|
||||
assert local_dt("2026-10-06T08:00:00+00:00") == "06/10/2026 10:00"
|
||||
|
||||
|
||||
def test_winter_time(local_dt):
|
||||
assert local_dt("2026-01-15T08:00:00+00:00") == "15/01/2026 09:00"
|
||||
|
||||
|
||||
def test_naive_is_utc(local_dt):
|
||||
assert local_dt("2026-10-06T08:00:00") == "06/10/2026 10:00"
|
||||
|
||||
|
||||
def test_datetime_object_and_format(local_dt):
|
||||
dt = datetime(2026, 10, 6, 8, 0, tzinfo=timezone.utc)
|
||||
assert local_dt(dt, "%H:%M") == "10:00"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("empty", [None, ""])
|
||||
def test_empty(local_dt, empty):
|
||||
assert local_dt(empty) == "-"
|
||||
Reference in New Issue
Block a user