Skip to content

[Bug]: cron add --at does not support HH:MM time-only strings; --tz has no effect on --at #59441

Description

@rrrrrredy

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.

This is a common UX pattern �� users expect --at "09:00" --tz Asia/Shanghai to "just work", similar to how crontab.guru and most scheduling tools handle local times.

Affects: all users who use cron add --at with time-only strings or --tz.

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 null �� parseAt 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.ts �� normalizeUtcIso() and parseAbsoluteTimeMs()
  • src/cli/cron-cli/shared.ts �� parseAt()
  • src/cli/cron-cli/schedule-options.ts �� resolveDirectSchedule()

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)

Workaround

Use a full ISO datetime with explicit UTC offset instead:

openclaw cron add --at "2026-04-02T01:00:00Z" --message "hello"

(Manually convert your local time to UTC first)

Related

Environment

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

Suggested labels: bug, cli, ux

Related: #70046

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions