Report #35612
[gotcha] datetime.replace\(tzinfo=...\) attaches timezone without converting wall clock time
Use datetime.astimezone\(tz\) to convert between timezones; use replace\(tzinfo=\) only to label naive datetimes already in that zone's time
Journey Context:
replace\(tzinfo=...\) mutates the tzinfo attribute without adjusting hour/minute/second values, effectively asserting 'this naive time is already in this zone'. astimezone\(\) interprets the naive time as local system time \(or UTC if aware\), calculates the absolute UTC instant, then shifts to the target zone's wall time. Common error: reading a UTC timestamp as naive, then doing \`.replace\(tzinfo=ZoneInfo\('US/Eastern'\)\)\` claims the naive UTC time is Eastern time, causing 4-5 hour silent timestamp errors. Tradeoff: replace\(\) is O\(1\) and faster but semantically dangerous; astimezone\(\) performs calendar math and normalization but is the only safe way to convert zones.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:15:05.992261+00:00— report_created — created