核心解析引擎 (Parser): 接收如 */5 * * * *、0 12 * * 1-5 这样标准的 Cron 字符串,能够识别星号(*)、列表(,)、范围(-)和步长(/)等特殊语法,并转化为计算机可高效读取的内部结构。 调度验证器 (Matcher): 提供一个核心方法:输入任意一个指定的时间点(年、月、日、时、分),系统能够迅速判断该时间是否被当前的 Cron 规则所命中(即:是否应该触发
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
Cron-Mbt
Cron-Mbtis a MoonBit cron expression library with a real parser, deterministic matcher, next-trigger calculator, and usable CLI. It is scoped to five-field cron expressions: minute, hour, day-of-month, month, and day-of-week. Time zones, seconds, and year fields are outside the current API boundary.What It Supports
*,?,,,-,/, andLfor the last day of month.Lis accepted only in the day-of-month field; invalid placements returnErr.@yearly,@annually,@monthly,@weekly,@daily,@midnight, and@hourly.0and7.Why This Revision Matters
The organizer feedback identified concrete gaps in CI, invalid-expression handling,
Lplacement, regression coverage, and release documentation. This revision addresses those items with explicit command stages, parser errors, calendar boundary tests, and a deterministic operations-style corpus.Project Layout
Installation
Add the module to your
moon.modimport block:Library Usage
Parse and inspect an expression:
Check whether a timestamp matches:
Compute the next trigger time:
CLI Usage
Parse:
Next trigger:
Match a timestamp:
Explain or validate operational input:
The current repository contains approximately 4,000 lines of effective MoonBit implementation and regression code, including the CLI and acceptance matrix. The source is organized around reusable scheduling operations rather than generated or duplicated filler.
Verification
The local and CI checks are:
The CI workflow uses the official stable MoonBit installer, prints
moon version --all, and runs the requiredmoon check,moon build,moon fmt,moon info, andmoon teststages on Ubuntu, macOS, and Windows. It also runs the CLI smoke suite on all three platforms. Local acceptance validation is kept compatible with MoonBit 0.10.3; the installer endpoint for that historical binary may return 403, so CI follows the currently available official stable channel.The deterministic acceptance corpus is under
benchmarks/; it covers operations-style schedules, month ends, leap years, calendar transitions, and weekday semantics.scripts/benchmark.ps1provides a repeatable end-to-end CLI baseline for the current machine. Its timings are regression data, not a portable performance claim.Mooncakes Status
cxh04/cron_mbt0.2.4moon publish --dry-runvalidates packaging before publication0.2.4contains the acceptance corpus, cross-platform CI, CLI smoke tests, business-calendar scheduling, and documentation fixesDocuments
License
Apache-2.0. See LICENSE.