Skip to content

fix(cron): use host timezone for conversation cron#652

Merged
tcp404 merged 1 commit into
mainfrom
boii/fix/cron-current-create-tz
Jul 23, 2026
Merged

fix(cron): use host timezone for conversation cron#652
tcp404 merged 1 commit into
mainfrom
boii/fix/cron-current-create-tz

Conversation

@tcp404

@tcp404 tcp404 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

cron current create (the conversation-helper CLI path) builds a schedule from a bare cron expression whose description refers to local wall-clock time (e.g. "every day at 12:00"), but stored no timezone. The scheduler resolves an absent tz as UTC, so on any non-UTC host the job fired at the wrong hour.

Reproduced on a UTC+8 host: 0 0 12 * * * ("daily at 12:00") computed its next run at 20:00 local (= 12:00 UTC), 8 hours off from what the schedule description promised.

Fix

Stamp the host's local IANA zone (via iana-time-zone, already a transitive dep of chrono) onto the conversation schedule, falling back to UTC only when the zone cannot be detected or is not in the tz database.

Scope is confined to the conversation-helper path:

  • The scheduler default (absent tz → UTC) is unchanged — the frontend /api/cron/jobs path already sends an explicit tz, so no other create path is affected.
  • New pure helpers local_timezone_name() + conversation_cron_schedule() in aionui-cron/service.rs.

Tests

  • conversation_cron_wires_local_timezone — deterministic: stamped tz is non-None and a valid IANA zone.
  • conversation_cron_fires_at_local_wall_clock — the schedule fires at 12:00 local wall-clock (guarded to skip when the host zone is undetectable).
  • cargo test -p aionui-cron: 184 lib + 73 integration pass; clippy -D warnings and fmt clean.

`cron current create` builds a schedule from a bare cron expression
whose description refers to local wall-clock time ("every day at
12:00"), but stored no timezone. The scheduler resolves an absent tz
as UTC, so on any non-UTC host the job fired at the wrong hour.

Stamp the host's local IANA zone (via iana-time-zone) onto the
conversation schedule, falling back to UTC only when the zone cannot
be detected. The scheduler default is left unchanged: the frontend
already sends an explicit tz, so no other create path is affected.
@tcp404
tcp404 merged commit 19b36f8 into main Jul 23, 2026
6 checks passed
@tcp404
tcp404 deleted the boii/fix/cron-current-create-tz branch July 23, 2026 07:08
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