openclaw - 💡(How to fix) Fix [Bug]: CronCreate: timezone mismatch — local tz set but UTC offset applied to cron expression [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#53669Fetched 2026-04-08 01:25:05
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×2commented ×1unsubscribed ×1

When using CronCreate with a local timezone (e.g. Asia/Shanghai), the model incorrectly applies UTC-offset arithmetic to the cron expression while keeping the local timezone string. This results in the job firing at the wrong local time.

Root Cause

When using CronCreate with a local timezone (e.g. Asia/Shanghai), the model incorrectly applies UTC-offset arithmetic to the cron expression while keeping the local timezone string. This results in the job firing at the wrong local time.

RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

When using CronCreate with a local timezone (e.g. Asia/Shanghai), the model incorrectly applies UTC-offset arithmetic to the cron expression while keeping the local timezone string. This results in the job firing at the wrong local time.

Steps to reproduce

Ask the model to schedule a task at a specific local time, e.g.: "Remind me every day at 6pm Shanghai time"

Observe the generated CronCreate call

Expected behavior

{ "cron": "0 18 * * *", "tz": "Asia/Shanghai" } Job fires at 18:00 Asia/Shanghai ✅

Actual behavior

{ "cron": "0 10 * * *", "tz": "Asia/Shanghai" } Model mentally converted 18:00 CST → 10:00 UTC, wrote the UTC value, but forgot to change tz to UTC — so the job fires at 10:00 Asia/Shanghai (8 hours early) ❌

OpenClaw version

2026.3.13

Operating system

Windows 11

Install method

No response

Model

claude-sonnet-4-6(通过 sw-onerouter-com 路由)

Provider / routing chain

oneroute

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

<img width="427" height="258" alt="Image" src="https://github.com/user-attachments/assets/65db8f46-2242-49c6-b619-f032a44b94dd" /> <img width="446" height="236" alt="Image" src="https://github.com/user-attachments/assets/fa05cb1d-be1d-4d95-bd82-23792e8b2e6e" />

extent analysis

Fix Plan

To fix the issue, we need to ensure that the cron expression is generated in the correct timezone. We can achieve this by:

  • Using a timezone-aware cron library
  • Setting the timezone to the desired local timezone (e.g. Asia/Shanghai) before generating the cron expression
  • Ensuring that the generated cron expression is not converted to UTC

Here's an example code snippet in Python:

import pytz
from datetime import datetime

def generate_cron_expression(timezone, hour, minute):
    # Set the timezone
    tz = pytz.timezone(timezone)
    
    # Generate the cron expression
    cron_expression = f"{minute} {hour} * * *"
    
    return cron_expression

# Example usage:
timezone = "Asia/Shanghai"
hour = 18
minute = 0

cron_expression = generate_cron_expression(timezone, hour, minute)
print(cron_expression)  # Output: 0 18 * * *

In this example, we use the pytz library to set the timezone to Asia/Shanghai and generate the cron expression accordingly.

Verification

To verify that the fix worked, you can:

  • Test the generate_cron_expression function with different timezones and times
  • Check that the generated cron expression is correct and fires at the expected local time

Extra Tips

  • Make sure to use a reliable timezone-aware library to handle timezone conversions
  • Always test your code with different timezones and edge cases to ensure correctness
  • Consider using a cron library that supports timezone-aware scheduling, such as apscheduler in Python.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

{ "cron": "0 18 * * *", "tz": "Asia/Shanghai" } Job fires at 18:00 Asia/Shanghai ✅

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: CronCreate: timezone mismatch — local tz set but UTC offset applied to cron expression [1 comments, 2 participants]