Function cron_parser::parse
source · pub fn parse<TZ: TimeZone>(
cron: &str,
dt: &DateTime<TZ>
) -> Result<DateTime<TZ>, ParseError>
Expand description
Parse cron expression
┌───────────────────── minute (0 - 59)
│ ┌─────────────────── hour (0 - 23)
│ │ ┌───────────────── dom (1 - 31) day of month
│ │ │ ┌─────────────── month (1 - 12)
│ │ │ │ ┌───────────── dow (0 - 6 or Sun - Sat) day of week (Sunday to Saturday)
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
* * * * * <command to execute>
Example
use cron_parser::parse;
use chrono::Utc;
assert!(parse("*/5 * * * *", &Utc::now()).is_ok());
// use custom timezone
use chrono_tz::US::Pacific;
assert!(parse("*/5 * * * *", &Utc::now().with_timezone(&Pacific)).is_ok());