[][src]Crate cron_parser

Library for parsing cron expressions with timezone support.

Example:

use chrono::{TimeZone, Utc};
use chrono_tz::Europe::Lisbon;
use cron_parser::parse;

fn main() {
   if let Ok(next) = parse("*/5 * * * *", &Utc::now()) {
        println!("when: {}", next);
   }

   // passing a custom timestamp
   if let Ok(next) = parse("0 0 29 2 *", &Utc.timestamp(1893456000, 0)) {
        println!("next leap year: {}", next);
        assert_eq!(next.timestamp(), 1961625600);
   }

   assert!(parse("2-3,9,*/15,1-8,11,9,4,5 * * * *", &Utc::now()).is_ok());
   assert!(parse("* * * * */Fri", &Utc::now()).is_err());

   // use custom timezone
   assert!(parse("*/5 * * * *", &Utc::now().with_timezone(&Lisbon)).is_ok());
}

Enums

ParseError

Functions

parse

Parse cron expression

parse_field

parse_field Allowed special characters: