Repository navigation
fix(proactive_engine): keep cron without tz on local DST rules - #1196
pcbeingused333 wants to merge 2 commits into
Conversation
A cron schedule with no explicit timezone used the fixed UTC offset of "now", so croniter computed the next run with a stale offset after a DST change (09:00 became 10:00). Use a naive local datetime so the system zone's DST rules apply. Co-authored-by: Claude (claude-sonnet-5-5) <noreply@anthropic.com>
A naive wall time inside the repeated hour of a DST fall-back maps to its first occurrence, which can already be past. Step to the next slot so the job fires once instead of being scheduled before now. Co-authored-by: Claude (claude-sonnet-5-5) <noreply@anthropic.com>
Windows compatibility review — PR #1196Reviewed head Finding1. Medium (Windows test failure, reproduced): both new tests call the POSIX-only The production change itself looks correct on Windows: with no Verification (native Windows 11, isolated detached worktree
|
Summary
_compute_next_runuseddatetime.now().astimezone().tzinfowhen a cron schedule had notz(the default, sincecron.default_timezoneis unset). That is a fixed UTC offset taken from "now", so croniter ignored DST for the next occurrence. WithTZ=America/New_York,0 9 * * *computed from 2027-03-13T15:00Z returned 10:00 EDT instead of 09:00, so a daily reminder fired an hour late after the change.With no
tz, the schedule now uses a naive localdatetime.fromtimestamp(...), so the system zone's DST rules apply. If the result falls in the repeated hour of a fall-back and is not afternow, it steps to the next slot, so the job fires once and is never scheduled in the past. Schedules with an explicittzare unchanged.Type
Verification
uv run pytest tests/test_cron_service_validation.py -q: 17 passed.test_cron_without_tz_follows_local_dstfails without the change.ruff checkandruff format --check(v0.15.12, as in pre-commit) on the touched files: clean.Relevant tests pass locally
Relevant lint / type checks pass locally
User-facing docs or screenshots are updated when needed
Risk
Related Issues
N/A
Co-authored-by: Claude (claude-sonnet-5-5) noreply@anthropic.com