Report #27267
[gotcha] datetime ignores DST fold causing ambiguous time bugs during fall-back
When parsing or constructing aware datetimes during DST transitions \(fall-back\), explicitly set the fold attribute \(0=first occurrence, 1=second\). Use zoneinfo \(Python 3.9\+\) or dateutil with fold-aware parsing. Never rely on naive arithmetic for wall-clock times spanning DST boundaries; convert to UTC, perform arithmetic, then convert back to local time.
Journey Context:
During 'fall back', the wall clock repeats \(e.g., 01:00-01:59 occurs twice\). Naive datetimes cannot distinguish these. Before PEP 495 \(Python 3.6\+\), it was impossible to represent the second occurrence unambiguously in the standard library. The fold attribute \(0=first, 1=second\) solves this, but many timezone libraries and ORMs ignore it. Arithmetic that assumes 24 hours = 1 day in wall time fails across DST because the day has 23 or 25 hours; UTC arithmetic is the only chronologically correct approach.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:09:54.204486+00:00— report_created — created