fix(cron): fix timezone display bug, add tz validation and skill docs

This commit is contained in:
Re-bin
2026-02-17 08:30:52 +00:00
parent 2c3a568e46
commit 6bae6a617f
5 changed files with 24 additions and 13 deletions

View File

@@ -719,17 +719,15 @@ def cron_list(
table.add_column("Status")
table.add_column("Next Run")
import datetime
import time
from datetime import datetime as _dt
from zoneinfo import ZoneInfo
for job in jobs:
# Format schedule
if job.schedule.kind == "every":
sched = f"every {(job.schedule.every_ms or 0) // 1000}s"
elif job.schedule.kind == "cron":
sched = job.schedule.expr or ""
if job.schedule.tz:
sched = f"{sched} ({job.schedule.tz})"
sched = f"{job.schedule.expr or ''} ({job.schedule.tz})" if job.schedule.tz else (job.schedule.expr or "")
else:
sched = "one-time"
@@ -737,13 +735,10 @@ def cron_list(
next_run = ""
if job.state.next_run_at_ms:
ts = job.state.next_run_at_ms / 1000
if job.schedule.kind == "cron" and job.schedule.tz:
try:
dt = datetime.fromtimestamp(ts, ZoneInfo(job.schedule.tz))
next_run = dt.strftime("%Y-%m-%d %H:%M")
except Exception:
next_run = time.strftime("%Y-%m-%d %H:%M", time.localtime(ts))
else:
try:
tz = ZoneInfo(job.schedule.tz) if job.schedule.tz else None
next_run = _dt.fromtimestamp(ts, tz).strftime("%Y-%m-%d %H:%M")
except Exception:
next_run = time.strftime("%Y-%m-%d %H:%M", time.localtime(ts))
status = "[green]enabled[/green]" if job.enabled else "[dim]disabled[/dim]"