MoonBit Cron is a zero-dependency, pure MoonBit library for parsing standard
five-field Cron expressions, matching times, and calculating the next trigger.
It is suitable for schedulers, automation tools, backend services, and CLIs.
Features
Parses minute, hour, day-of-month, month, and day-of-week fields.
Supports *, values, ranges (a-b), lists (a,b), and steps (*/n).
Supports uppercase month aliases (JAN through DEC) and weekday aliases
(SUN through SAT).
Rejects malformed input, out-of-range values, non-positive steps, and
oversized numeric fields before integer overflow.
Uses standard Cron day-of-month/day-of-week OR semantics.
Finds the next matching minute across month and leap-year boundaries.
Exposes CronExpr::to_string() for canonical serialization and config
round-tripping.
Supports wasm, wasm-gc, JavaScript, and native targets.
Provides a deterministic in-memory scheduler with task lifecycle and retry
policies.
Includes task configuration parsing, dependency validation, conflict
detection, audit history, health reports, preflight checks, and snapshots.
Install MoonBit with the official installer, then add the package from
Mooncakes:
moon add lijunjie860/moonbit_cron
To develop locally:
git clone https://github.com/lijunjie860/MoonBit-Cron.git
cd MoonBit-Cron
moon check --target all --warn-list +73 --deny-warn
moon test --target all --warn-list +73 --deny-warn
moon run cmd/main
CronExpr::to_string() emits a normalized numeric form. Named aliases such
as JAN and MON are parsed correctly and serialize to their numeric values,
which makes persisted schedules deterministic.
Validation
The GitHub Actions workflow installs the latest official MoonBit toolchain,
formats its isolated checkout, then runs warning-free checks, builds,
generated-interface generation, and tests on Ubuntu, macOS, and Windows.
Run the same checks locally:
moon fmt --check
moon check --target all --warn-list +73 --deny-warn
moon build --target all --warn-list +73 --deny-warn
moon test --target all --warn-list +73 --deny-warn
moon info
Task definitions use the stable format id|cron|enabled|max_attempts:
backup|0 2 * * *|true|3
report|0 9 * * 1-5|true|1
Applications can load the document with parse_task_document, validate it
with preflight, build bounded ExecutionPlan values, and record outcomes in
an AuditLog. SchedulerReport and SchedulerSnapshot provide stable text
summaries for health endpoints and operational runbooks.
License
Copyright (c) 2026 lijunjie860. Licensed under the MIT License.
MoonBit Cron
MoonBit Cronis a zero-dependency, pure MoonBit library for parsing standard five-field Cron expressions, matching times, and calculating the next trigger. It is suitable for schedulers, automation tools, backend services, and CLIs.Features
*, values, ranges (a-b), lists (a,b), and steps (*/n).JANthroughDEC) and weekday aliases (SUNthroughSAT).CronExpr::to_string()for canonical serialization and config round-tripping.Install
Install MoonBit with the official installer, then add the package from Mooncakes:
To develop locally:
API example
Runnable CLI demonstration
Expected output:
CronExpr::to_string()emits a normalized numeric form. Named aliases such asJANandMONare parsed correctly and serialize to their numeric values, which makes persisted schedules deterministic.Validation
The GitHub Actions workflow installs the latest official MoonBit toolchain, formats its isolated checkout, then runs warning-free checks, builds, generated-interface generation, and tests on Ubuntu, macOS, and Windows.
Run the same checks locally:
See CHANGELOG.md for release history.
Production scheduler workflow
Task definitions use the stable format
id|cron|enabled|max_attempts:Applications can load the document with
parse_task_document, validate it withpreflight, build boundedExecutionPlanvalues, and record outcomes in anAuditLog.SchedulerReportandSchedulerSnapshotprovide stable text summaries for health endpoints and operational runbooks.License
Copyright (c) 2026 lijunjie860. Licensed under the MIT License.