Report #103835
[gotcha] Mixing naive and aware datetimes causes silent wrong-time or TypeError bugs
Always use aware datetimes for stored timestamps and interoperability. Create them with \`datetime.now\(timezone.utc\)\` or \`datetime.fromtimestamp\(ts, tz=timezone.utc\)\`. Convert naive to aware only when you know the zone, and never compare or subtract across the two kinds.
Journey Context:
A naive datetime is just a wall-clock tuple; it does not represent an unambiguous point in time because it lacks offset and DST context. \`datetime.utcnow\(\)\` is still naive and is a common trap. Comparisons between naive and aware datetimes raise TypeError for ordering and are silently unequal for equality, which can mask stale-data bugs. Store and compute in UTC, convert to local only at display boundaries, and use \`zoneinfo\` \(3.9\+\) or \`dateutil\`/\`pytz\` for IANA zones.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:47:18.837588+00:00— report_created — created