Files
WealthySmart/backend/app/timeutil.py
Carlos Escalante 996bd437a1 Replace deprecated datetime.utcnow with shared naive-UTC helper
All 29 call sites now use app.timeutil.utcnow(), which returns naive
UTC via the non-deprecated API. Semantics are unchanged on purpose:
every datetime column is TIMESTAMP WITHOUT TIME ZONE, so going aware
here would poison naive/aware comparisons. The TIMESTAMPTZ migration
(Phase 2) now has a single place to change. (BE-01)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 19:46:54 -06:00

15 lines
594 B
Python

from datetime import datetime, timezone
def utcnow() -> datetime:
"""Naive UTC now, via the non-deprecated API.
Every datetime column in the schema is TIMESTAMP WITHOUT TIME ZONE, so the
whole app speaks naive-UTC. Replacing datetime.utcnow() call sites with
this helper removes the Python 3.12 deprecation without changing any
stored value or comparison. When the columns move to TIMESTAMPTZ
(Phase 2), this becomes `datetime.now(timezone.utc)` and the type change
happens in exactly one place.
"""
return datetime.now(timezone.utc).replace(tzinfo=None)