Skip to content

fix(cron): naive ISO timestamps stored without timezone — jobs fire at wrong time - #1729

Merged
teknium1 merged 1 commit into
mainfrom
fix/cron-timezone-naive-iso
Mar 17, 2026
Merged

fix(cron): naive ISO timestamps stored without timezone — jobs fire at wrong time#1729
teknium1 merged 1 commit into
mainfrom
fix/cron-timezone-naive-iso

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

User-provided ISO timestamps like 2026-02-03T14:00 (no timezone) were stored as naive datetimes. At check time, _ensure_aware() interprets them using the current system timezone. If the system timezone changes between job creation and checking (e.g., server migration, DST change), the job fires at the wrong wall-clock time.

What changed

  • cron/jobs.py: In parse_schedule(), call dt.astimezone() on naive datetimes to immediately stamp them with the local timezone. The stored run_at value is now always timezone-aware (e.g., 2026-02-03T14:00:00-08:00), so it's stable regardless of later timezone changes.

Timestamps that already include timezone info (e.g., 2026-02-03T14:00+02:00 or Z) are unaffected.

Test plan

  • python -m pytest tests/cron/ -n0 -q → 54 passed, 3 skipped ✔
  • Create a job with 2026-06-01T09:00 → verify stored run_at includes timezone offset

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.
@teknium1
teknium1 merged commit fb20a9e into main Mar 17, 2026
1 check passed
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…one-naive-iso

fix(cron): naive ISO timestamps stored without timezone — jobs fire at wrong time
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…one-naive-iso

fix(cron): naive ISO timestamps stored without timezone — jobs fire at wrong time
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…one-naive-iso

fix(cron): naive ISO timestamps stored without timezone — jobs fire at wrong time
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…one-naive-iso

fix(cron): naive ISO timestamps stored without timezone — jobs fire at wrong time
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…one-naive-iso

fix(cron): naive ISO timestamps stored without timezone — jobs fire at wrong time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant