Module std::time::cron

Cron expression parsing and scheduling.

Parse cron expressions and compute the next firing time relative to a given epoch timestamp.

Examples

import std.time.cron;
import std.time.datetime;

fn main() {
    let expr = cron.parse("0 */5 * * *");
    let next_run = expr.next(datetime.now_secs());
    println(next_run);
    expr.close();
}

Contents

Functions

Function parse

pub fn parse(expr: string) -> Expr

Parse a cron expression string.

Panics if the expression syntax is invalid.

Examples

import std.time.cron;

fn main() {
    let every_minute = cron.parse("* * * * *");
    let weekdays_9am = cron.parse("0 9 * * 1-5");
}

Types

Struct Expr

Fields

handle: ExprHandle

Enum CronError

Structured cron scheduling errors surfaced by the native ABI.

Variants

NoNextOccurrence(string)
InvalidInput(string)
InvalidEpoch(string)

Traits

Trait ExprMethods

Methods available on a parsed Expr.

Methods

fn next(self: Self, after_epoch_secs: i64) -> i64

Compute the next firing time (epoch seconds) after the given timestamp.

fn try_next(self: Self, after_epoch_secs: i64) -> Result<i64, CronError>

Compute the next firing time (epoch seconds) after the given timestamp.

Returns Err(CronError) when the schedule has no future match or the native ABI rejects the input.

fn to_string(self: Self) -> string

Return the cron expression as a string.