forked from mtusi2026/mtusi2026lab2
ЛР 2: PostgreSQL и сессии, оценка 3
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
"""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')
|
||||
Reference in New Issue
Block a user