NovaGuide / src /utils /timing.py
DKLPDV15\eB
Deploy NovaGuide with versioned runtime configuration
7ca0188
Raw History Blame Contribute Delete
524 Bytes
"""UTC timestamp and elapsed-time helpers."""
from datetime import datetime, timezone
from time import time_ns
def current_utc_iso() -> str:
"""Return a timezone-aware UTC timestamp in ISO 8601 format."""
return datetime.now(timezone.utc).isoformat()
def now_ms() -> int:
"""Return Unix time in integer milliseconds."""
return time_ns() // 1_000_000
def elapsed_ms(start_ms: int) -> int:
"""Return non-negative elapsed milliseconds since ``start_ms``."""
return max(0, now_ms() - start_ms)