Report #5676
[gotcha] datetime.replace\(tzinfo=...\) creates incorrect time instead of converting timezone
Use datetime.astimezone\(tz\) to convert a naive datetime to an aware one in a specific timezone. Only use .replace\(tzinfo=\) when explicitly asserting 'this naive time is already in this zone' without conversion.
Journey Context:
replace\(tzinfo=...\) mutates the tzinfo attribute but keeps the year/month/day/hour/minute/second values identical. If you have a naive datetime representing UTC and call .replace\(tzinfo=EST\), Python interprets the wall-clock time as EST instead of converting 10:00 UTC to 05:00 EST. This causes scheduling bugs where all times are interpreted as the local server time regardless of the specified zone.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:51:04.915648+00:00— report_created — created