gateway/modules/shared/timezoneUtils.py
2025-10-24 23:57:17 +02:00

37 lines
980 B
Python

"""
Timezone utilities for consistent timestamp handling across the gateway.
Ensures all timestamps are properly handled as UTC.
"""
from datetime import datetime, timezone
import time
def get_utc_now() -> datetime:
"""
Get current time in UTC with timezone info.
Returns:
datetime: Current UTC time with timezone info
"""
return datetime.now(timezone.utc)
def get_utc_timestamp() -> float:
"""
Get current UTC timestamp (seconds since epoch with millisecond precision).
Returns:
float: Current UTC timestamp in seconds with millisecond precision
"""
return time.time()
def create_expiration_timestamp(expires_in_seconds: int) -> float:
"""
Create a new expiration timestamp from seconds until expiration.
Args:
expires_in_seconds (int): Seconds until expiration
Returns:
float: UTC timestamp in seconds
"""
return get_utc_timestamp() + expires_in_seconds