Lab3: HAProxy, API replicas, idempotency for grade 4

This commit is contained in:
2026-11-11 01:29:57 +03:00
parent 0ab3a341aa
commit 9f25648c1b
37 changed files with 2083 additions and 26 deletions
+20
View File
@@ -0,0 +1,20 @@
"""Форматирование времени в RFC 3339 UTC с миллисекундами и Z."""
from datetime import datetime, timezone
def now_utc() -> str:
return format_utc(datetime.now(timezone.utc))
def format_utc(value: datetime) -> str:
if value.tzinfo is None:
value = value.replace(tzinfo=timezone.utc)
else:
value = value.astimezone(timezone.utc)
return value.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
def parse_rfc3339(value: str) -> datetime:
if value.endswith("Z"):
value = value[:-1] + "+00:00"
return datetime.fromisoformat(value)