Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(cron): add timezone support for accurate next run time calculation
Ahwei153c83e340c5
diff --git a/nanobot/cron/service.py b/nanobot/cron/service.pyindex d1965a9ec..6fea4de70 100644--- a/nanobot/cron/service.py+++ b/nanobot/cron/service.py@@ -4,6 +4,7 @@ import asyncioimport jsonimport timeimport uuid+from datetime import datetimefrom pathlib import Pathfrom typing import Any, Callable, Coroutine@@ -30,9 +31,18 @@ def _compute_next_run(schedule: CronSchedule, now_ms: int) -> int | None:if schedule.kind == "cron" and schedule.expr:try:from croniter import croniter- cron = croniter(schedule.expr, time.time())- next_time = cron.get_next()- return int(next_time * 1000)+ from zoneinfo import ZoneInfo+ base_time = time.time()+ if schedule.tz:+ tz = ZoneInfo(schedule.tz)+ base_dt = datetime.fromtimestamp(base_time, tz=tz)+ cron = croniter(schedule.expr, base_dt)+ next_dt = cron.get_next(datetime)+ return int(next_dt.timestamp() * 1000)+ else:+ cron = croniter(schedule.expr, base_time)+ next_time = cron.get_next()+ return int(next_time * 1000)except Exception:return None