Skip to main content

Crate philiprehberger_cron_parser

Crate philiprehberger_cron_parser 

Source
Expand description

§philiprehberger-cron-parser

Cron expression parsing, scheduling, and human-readable descriptions. Zero external dependencies — uses only the standard library.

§Quick Start

use philiprehberger_cron_parser::{CronExpr, DateTime};

let expr = CronExpr::parse("*/15 * * * *").unwrap();
let now = DateTime { year: 2026, month: 3, day: 15, hour: 10, minute: 3, second: 0 };
let next = expr.next_from(&now).unwrap();
assert_eq!(next, DateTime { year: 2026, month: 3, day: 15, hour: 10, minute: 15, second: 0 });

// Human-readable description
assert_eq!(expr.describe(), "Every 15 minutes");

§Supported Syntax

Standard 5-field cron: minute hour day-of-month month day-of-week

Each field supports: single values (5), ranges (1-5), steps (*/15, 1-5/2), lists (1,3,5), and wildcards (*).

Aliases: @hourly, @daily, @midnight, @weekly, @monthly, @yearly, @annually

Structs§

CronExpr
A parsed cron expression.
DateTime
A simple UTC date-time with second precision.

Enums§

ParseError
Errors that can occur when parsing a cron expression.

Functions§

day_of_week
Returns the day of the week for a given date. 0 = Sunday, 1 = Monday, …, 6 = Saturday.
days_in_month
Returns the number of days in the given month (1-12) for the given year.
is_leap_year
Returns true if year is a leap year.