Report #46556
[gotcha] Datetime timedelta arithmetic is silently wrong across DST transitions
Never use naive datetimes for arithmetic that might cross timezone transitions. Always use timezone-aware datetimes \(\`datetime.now\(timezone.utc\)\` or \`zoneinfo\`\) when adding \`timedelta\`. If you need 'same wall-clock time tomorrow' rather than '24 hours later', use \`dateutil.relativedelta\` or construct the new datetime manually, do not use \`timedelta\(days=1\)\` on naive times.
Journey Context:
Naive datetimes perform pure tuple arithmetic \(add 24 hours to hour field\). When crossing a 'spring forward' DST transition \(23h day\), naive arithmetic puts the time at 24:00 \(next day 00:00\), which is correct wall-clock, but when crossing 'fall back' \(25h day\), it puts it at 24:00 which is 23:00 wall-clock the same day - an off-by-one-hour error. Aware datetimes convert to UTC, add the delta, then convert back, preserving absolute elapsed time \(24h real seconds\). Developers choose naive times to avoid 'complexity', then silently corrupt scheduling systems twice yearly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:37:04.968869+00:00— report_created — created