19 lines
494 B
Python
19 lines
494 B
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
def now_iso_utc() -> str:
|
|
return datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")
|
|
|
|
|
|
def is_iso_utc(value: str) -> bool:
|
|
try:
|
|
# Accept the 'Z' suffix
|
|
if value.endswith("Z"):
|
|
datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
else:
|
|
datetime.fromisoformat(value)
|
|
return True
|
|
except Exception:
|
|
return False |