[−][src]Function cron_parser::parse_field
pub fn parse_field(
field: &str,
min: u32,
max: u32
) -> Result<BTreeSet<u32>, ParseError>
parse_field Allowed special characters:
*
any value,
value list separator-
range of values/
step values
minutes min: 0, max: 59
hours min: 0, max: 23
days min: 1, max: 31
month min: 1, max: 12
dweek min: 0, max: 6 or min: Sun, max Sat
Day of week
Sun = 0
Mon = 1
Tue = 2
Wed = 3
Thu = 4
Fri = 5
Sat = 6
The field column can have a *
or a list of elements separated by commas.
An element is either a number in the ranges or two numbers in the range
separated by a hyphen, slashes can be combined with ranges to specify
step values
Example
use cron_parser::parse_field; use std::collections::BTreeSet; fn main() { // every 3 months assert_eq!(parse_field("*/3", 1, 12).unwrap(), BTreeSet::<u32>::from([1,4,7,10].iter().cloned().collect())); // day 31 assert_eq!(parse_field("31", 1, 31).unwrap(), BTreeSet::<u32>::from([31].iter().cloned().collect())); // every minute from 40 through 50 assert_eq!(parse_field("40-50", 0, 59).unwrap(), BTreeSet::<u32>::from([40,41,42,43,44,45,46,47,48,49,50].iter().cloned().collect())); // at hour 3,15,23 assert_eq!(parse_field("15,3,23", 0, 23).unwrap(), BTreeSet::<u32>::from([3,15,23].iter().cloned().collect())); }