Milestone 1.
This commit is contained in:
19
app/utils/time.py
Normal file
19
app/utils/time.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
Reference in New Issue
Block a user