14 lines
393 B
Python
14 lines
393 B
Python
|
|
"""Shared time utilities; timezone-aware UTC to avoid deprecated datetime.utcnow."""
|
||
|
|
|
||
|
|
from datetime import datetime, timezone
|
||
|
|
|
||
|
|
|
||
|
|
def utc_now() -> datetime:
|
||
|
|
"""Return current UTC time (timezone-aware). Prefer over datetime.utcnow()."""
|
||
|
|
return datetime.now(timezone.utc)
|
||
|
|
|
||
|
|
|
||
|
|
def utc_now_iso() -> str:
|
||
|
|
"""Return current UTC time as ISO format string."""
|
||
|
|
return utc_now().isoformat()
|