forked from mtusi2026/mtusi2026lab2
10 lines
385 B
Python
10 lines
385 B
Python
"""Contract requires RFC3339 UTC timestamps with a literal Z suffix."""
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
def utc_z(value: datetime) -> str:
|
|
if value.tzinfo is None:
|
|
# Database columns are TIMESTAMPTZ, but keep the serializer defensive.
|
|
value = value.replace(tzinfo=timezone.utc)
|
|
return value.astimezone(timezone.utc).isoformat().replace('+00:00', 'Z')
|