Skip to content

fix(cron): Apply timezone from schedule.TZ for cron expressions#1092

Closed
liugangjian wants to merge 1 commit intosipeed:mainfrom
liugangjian:fix/1044-cron-timezone
Closed

fix(cron): Apply timezone from schedule.TZ for cron expressions#1092
liugangjian wants to merge 1 commit intosipeed:mainfrom
liugangjian:fix/1044-cron-timezone

Conversation

@liugangjian
Copy link
Copy Markdown

Description

Fixes #1044

Cron expressions currently ignore the schedule.TZ field and always evaluate in UTC, causing jobs to trigger at incorrect local times.

Changes

  • Added 3-tier fallback for timezone handling:
    1. Job-specific: schedule.TZ from individual cron job
    2. Server-wide: tools.cron.default_timezone from config
    3. Hardcoded: "Asia/Shanghai" as final fallback
  • Updated computeNextRun() to convert reference time to target timezone before evaluation
  • Added default_timezone config option in tools.cron section
  • Enhanced tool parameters to support timezone field

Example

Before: cron expression 0 9 * * * triggers at UTC 9:00 (17:00 CST)
After: cron expression 0 9 * * * triggers at local 9:00 when TZ is set correctly

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

AI Code Generation

  • 🤖 AI Assisted - Human designed the solution, AI helped implement it

Checklist

  • I have run make check and all checks pass
  • My code follows the style guidelines of this project

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 5, 2026

CLA assistant check
All committers have signed the CLA.

@sipeed-bot
Copy link
Copy Markdown

sipeed-bot bot commented Mar 25, 2026

@liugangjian Hi! This PR has had no activity for over 2 weeks, so I'm closing it for now to keep things organized. Feel free to reopen anytime if you'd like to continue.

@sipeed-bot sipeed-bot bot closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Cron expressions ignore schedule.TZ field, always evaluate in UTC

2 participants