Files
classifieds/app/utils/time.py
T
2026-07-13 16:52:00 -04:00

15 lines
565 B
Python

"""Time helpers.
`datetime.utcnow()` is deprecated on Python 3.12+. This helper preserves the
existing *naive UTC* semantics the codebase relies on (DB columns are naive
`DateTime`, and comparisons assume naive UTC) while avoiding the deprecation:
we build an aware UTC datetime and strip the tzinfo, yielding the exact same
value `datetime.utcnow()` used to return.
"""
from datetime import datetime, timezone
def utcnow() -> datetime:
"""Current UTC time as a naive datetime (tzinfo stripped)."""
return datetime.now(timezone.utc).replace(tzinfo=None)