From 5301c01776e39fc9461578a30498bf2bf3034556 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Tue, 17 Mar 2026 04:20:24 -0700 Subject: [PATCH] fix(cron): make naive ISO timestamps timezone-aware at parse time User-provided ISO timestamps like '2026-02-03T14:00' (no timezone) were stored naive. The _ensure_aware() helper at check time interprets naive datetimes using the current system timezone, but if the system timezone changes between job creation and checking, the job fires at the wrong time. Fix: call dt.astimezone() at parse time to immediately stamp the datetime with the local timezone. The stored value is now always timezone-aware, so it's stable regardless of later timezone changes. --- cron/jobs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cron/jobs.py b/cron/jobs.py index a647a18b5..30d20f1e3 100644 --- a/cron/jobs.py +++ b/cron/jobs.py @@ -168,6 +168,10 @@ def parse_schedule(schedule: str) -> Dict[str, Any]: try: # Parse and validate dt = datetime.fromisoformat(schedule.replace('Z', '+00:00')) + # Make naive timestamps timezone-aware at parse time so the stored + # value doesn't depend on the system timezone matching at check time. + if dt.tzinfo is None: + dt = dt.astimezone() # Interpret as local timezone return { "kind": "once", "run_at": dt.isoformat(),