From afaeb64636165ff38fa03eb25e00fe77e10c658c Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 11 May 2026 13:28:49 -0400 Subject: [PATCH] fix: UTC timezone suffix missing from all isoformat() timestamp outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit db.py returned all datetime columns (first_seen, last_seen, resolved_at, created_at, expires_at) as bare ISO strings like "2026-03-14T14:14:21" with no timezone marker. Per the ECMAScript spec, new Date() on a datetime string without timezone treats it as LOCAL time, not UTC. This made lt.time.ago() and stale-detection wrong for any user whose browser is not in UTC — event ages and stale warnings would be off by the client's UTC offset. monitor.py had the same issue on the network_snapshot 'updated' field. Fix: append 'Z' to all isoformat() calls (UTC datetimes confirmed by MySQL server timezone and _now_utc() pattern used throughout codebase). Co-Authored-By: Claude Sonnet 4.6 --- db.py | 8 ++++---- monitor.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db.py b/db.py index 9791c67..3e60cd2 100644 --- a/db.py +++ b/db.py @@ -182,7 +182,7 @@ def get_active_events(limit: int = 200, offset: int = 0) -> list: for r in rows: for k in ('first_seen', 'last_seen'): if r.get(k) and hasattr(r[k], 'isoformat'): - r[k] = r[k].isoformat() + r[k] = r[k].isoformat() + 'Z' return rows @@ -210,7 +210,7 @@ def get_recent_resolved(hours: int = 24, limit: int = 50) -> list: for r in rows: for k in ('first_seen', 'last_seen', 'resolved_at'): if r.get(k) and hasattr(r[k], 'isoformat'): - r[k] = r[k].isoformat() + r[k] = r[k].isoformat() + 'Z' return rows @@ -252,7 +252,7 @@ def get_active_suppressions() -> list: for r in rows: for k in ('created_at', 'expires_at'): if r.get(k) and hasattr(r[k], 'isoformat'): - r[k] = r[k].isoformat() + r[k] = r[k].isoformat() + 'Z' return rows @@ -267,7 +267,7 @@ def get_suppression_history(limit: int = 50) -> list: for r in rows: for k in ('created_at', 'expires_at'): if r.get(k) and hasattr(r[k], 'isoformat'): - r[k] = r[k].isoformat() + r[k] = r[k].isoformat() + 'Z' return rows diff --git a/monitor.py b/monitor.py index 445912d..d0c5463 100644 --- a/monitor.py +++ b/monitor.py @@ -918,7 +918,7 @@ class NetworkMonitor: return { 'hosts': hosts, 'unifi': display_unifi, - 'updated': datetime.utcnow().isoformat(), + 'updated': datetime.utcnow().isoformat() + 'Z', } # ------------------------------------------------------------------