openclaw - ✅(Solved) Fix [Bug]: cron add --at does not support HH:MM time-only strings; --tz has no effect on --at [1 pull requests, 1 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#59441Fetched 2026-04-08 02:25:08
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
referenced ×4cross-referenced ×3

openclaw cron add --at "HH:MM" --tz <IANA> fails with "Invalid --at" because time-only strings (HH:MM) are not recognized by the parser. Additionally, --tz has no effect on --at even when using supported datetime formats, making timezone-aware one-shot scheduling non-intuitive from the CLI.

Error Message

Attempt: time-only string

openclaw cron add --name "test" --at "09:00" --tz "Asia/Shanghai" --message "hello"

Error: Invalid --at; use ISO time or duration like 20m

Root Cause

openclaw cron add --at "HH:MM" --tz <IANA> fails with "Invalid --at" because time-only strings (HH:MM) are not recognized by the parser. Additionally, --tz has no effect on --at even when using supported datetime formats, making timezone-aware one-shot scheduling non-intuitive from the CLI.

Fix Action

Fixed

PR fix notes

PR #59444: fix(cron): support HH:MM time-only strings in --at; apply --tz to time-only input

Description (problem / solution / changelog)

Summary

Fixes #59441

Before this change, openclaw cron add --at "09:00" --tz Asia/Shanghai threw Invalid --at because bare HH:MM strings were not recognised by parseAbsoluteTimeMs / normalizeUtcIso in src/cron/parse.ts.

Additionally, --tz had no effect on --at for time-only inputs since parseAt() only applied timezone resolution to strings matching the full offset-less ISO datetime regex (YYYY-MM-DDTHH:MM).

Changes

src/cli/cron-cli/shared.ts

  • Add TIME_ONLY_RE regex to match HH:MM and HH:MM:SS inputs
  • Add getUtcDateString() helper — returns today in UTC (YYYY-MM-DD)
  • Add getTodayDateInTimeZone(tz) helper — returns today in the given IANA timezone using Intl.DateTimeFormat
  • In parseAt(): when input matches the time-only pattern, expand to a full offset-less ISO datetime using today's date in the given timezone (or UTC if no --tz supplied), then resolve via the existing parseOffsetlessIsoDateTimeInTimeZone path

src/cli/cron-cli/parse-at.test.ts (new)

Unit tests covering:

  • HH:MM with --tz Asia/Shanghai → correct UTC conversion
  • HH:MM without --tz → treated as UTC
  • HH:MM:SS with seconds
  • Existing offset-less ISO datetime path still works
  • Existing relative duration path still works
  • Invalid input returns null

Why not change src/cron/parse.ts?

parseAbsoluteTimeMs is a lower-level utility called from multiple contexts (including list display). A bare HH:MM string is ambiguous without a date — the fix belongs in the CLI parseAt layer which has access to the --tz option and can supply today's date.

Before / After

# Before
$ openclaw cron add --name "standup" --at "09:00" --tz "Asia/Shanghai" --message "standup"
Error: Invalid --at; use ISO time or duration like 20m

# After
$ openclaw cron add --name "standup" --at "09:00" --tz "Asia/Shanghai" --message "standup"
✓ Created cron job — fires today at 09:00 Asia/Shanghai (01:00 UTC)

Changed files

  • src/cli/cron-cli/parse-at.test.ts (added, +84/-0)
  • src/cli/cron-cli/shared.ts (modified, +59/-3)

Code Example

# Attempt: time-only string
openclaw cron add --name "test" --at "09:00" --tz "Asia/Shanghai" --message "hello"
# Error: Invalid --at; use ISO time or duration like 20m
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

openclaw cron add --at "HH:MM" --tz <IANA> fails with "Invalid --at" because time-only strings (HH:MM) are not recognized by the parser. Additionally, --tz has no effect on --at even when using supported datetime formats, making timezone-aware one-shot scheduling non-intuitive from the CLI.

Steps to reproduce

# Attempt: time-only string
openclaw cron add --name "test" --at "09:00" --tz "Asia/Shanghai" --message "hello"
# Error: Invalid --at; use ISO time or duration like 20m

Expected behavior

--at "09:00" --tz Asia/Shanghai should schedule the job at 09:00 in the given timezone today. At minimum, the error message should clearly state what formats are accepted.

Actual behavior

Bug 1 — HH:MM not supported at all:

src/cron/parse.ts normalizeUtcIso() only handles three patterns:

  • YYYY-MM-DD → appends T00:00:00Z
  • YYYY-MM-DDTHH:MM → appends Z
  • strings with timezone suffix (Z / +08:00) → pass through

A bare HH:MM string falls through all branches, is returned unchanged, and Date.parse("09:00") returns NaN on most platforms. Result: parseAbsoluteTimeMs returns nullparseAt returns null → CLI throws "Invalid --at".

Bug 2 — --tz silently ignored for --at:

src/cli/cron-cli/shared.ts parseAt() only applies timezone when isOffsetlessIsoDateTime(raw) is true. That regex is /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/ — time-only strings never reach the timezone branch. The --help text says --tz is "Timezone for cron expressions", implying it only applies to --cron. But users naturally expect --at "09:00" --tz Asia/Shanghai to work.

Relevant code

  • src/cron/parse.tsnormalizeUtcIso() and parseAbsoluteTimeMs()
  • src/cli/cron-cli/shared.tsparseAt()
  • src/cli/cron-cli/schedule-options.tsresolveDirectSchedule()

Suggested fix

  1. Add HH:MM / HH:MM:SS pattern support: when --tz is provided and input matches HH:MM, resolve it as today's wall-clock time in that timezone
  2. Update --help text to clarify --tz scope (applies to --cron and offset-less --at, not bare time strings)

Environment

  • OpenClaw: checked against main branch
  • Node.js: v22.12.0
  • OS: Linux (sandbox)
  • Reproduction: consistent

extent analysis

TL;DR

  • To fix the issue, add support for HH:MM and HH:MM:SS time formats in the normalizeUtcIso() function and update the --help text to clarify the scope of --tz.

Guidance

  • Modify the normalizeUtcIso() function in src/cron/parse.ts to handle HH:MM and HH:MM:SS patterns by resolving them as today's wall-clock time in the provided timezone when --tz is given.
  • Update the parseAt() function in src/cli/cron-cli/shared.ts to apply the timezone when --at is used with a time-only string and --tz is provided.
  • Clarify the --help text for --tz to indicate it applies to both --cron and offset-less --at inputs, including time-only strings when a timezone is specified.

Example

// Example modification to handle HH:MM pattern in normalizeUtcIso()
if (input.match(/^\d{2}:\d{2}$/)) {
  const timezone = // retrieve timezone from --tz option
  const today = new Date();
  today.setHours(0, 0, 0, 0); // Reset to start of day
  const [hours, minutes] = input.split(':').map(Number);
  today.setHours(hours, minutes, 0, 0); // Set time to input
  // Convert today to UTC ISO string considering the timezone
  return today.toISOString();
}

Notes

  • The exact implementation details may vary based on the specific requirements and constraints of the OpenClaw project.
  • It's essential to test the modifications thoroughly to ensure they work correctly across different timezones and input formats.

Recommendation

  • Apply workaround: Modify the normalizeUtcIso() function and update the --help text as suggested to support HH:MM and HH:MM:SS time formats and clarify the use of --tz. This approach directly addresses the reported issues and provides a clear path for users to schedule jobs with time-only strings and timezones.

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

--at "09:00" --tz Asia/Shanghai should schedule the job at 09:00 in the given timezone today. At minimum, the error message should clearly state what formats are accepted.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING