forked from mtusi2026/mtusi2026lab5
16 lines
437 B
Python
16 lines
437 B
Python
"""UTC timestamps rendered as RFC 3339 with a Z suffix."""
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
def utcnow() -> datetime:
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
def iso(value: datetime) -> str:
|
|
if value.tzinfo is None:
|
|
value = value.replace(tzinfo=timezone.utc)
|
|
value = value.astimezone(timezone.utc)
|
|
return value.strftime("%Y-%m-%dT%H:%M:%S.") + f"{value.microsecond:06d}Z"
|