feat: add bgp observability and admin ui improvements
This commit is contained in:
20
backend/app/core/time.py
Normal file
20
backend/app/core/time.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""Time helpers for API serialization."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
|
||||
def ensure_utc(value: datetime | None) -> datetime | None:
|
||||
if value is None:
|
||||
return None
|
||||
if value.tzinfo is None:
|
||||
return value.replace(tzinfo=UTC)
|
||||
return value.astimezone(UTC)
|
||||
|
||||
|
||||
def to_iso8601_utc(value: datetime | None) -> str | None:
|
||||
normalized = ensure_utc(value)
|
||||
if normalized is None:
|
||||
return None
|
||||
return normalized.isoformat().replace("+00:00", "Z")
|
||||
Reference in New Issue
Block a user