"The" answer doesn't exist for practically anything above passive infrastructure.

We can barely tell the time😄

"Yeah, that replace(tzinfo) trick is sneaky because it assumes the naive time is already in local without shifting, but if anything else (like SQLite's ISO parse or a later astimezone) treats it as UTC first, boom, extra hour. Storing in UTC keeps it clean: parse to local aware, convert once to UTC for the DB, then convert back only when showing.I tweaked your line to this for the parse: local_aware = naive_local.replace(tzinfo=LOCAL_TZ); utc_for_db = local_aware.astimezone(ZoneInfo('UTC')). And for retrieval, just astimezone back to LOCAL_TZ. Tested it with Berlin on that Oct 15 date—'6PM' goes in as 16:00 UTC, comes out 6PM CEST, spot on. If your input parsing's got extras (like dateutil), paste that bit and I'll adjust."

Reply to this note

Please Login to reply.

Discussion

No replies yet.