Skip to content

Instantly share code, notes, and snippets.

@ayrat555
Created September 22, 2018 20:11
Show Gist options
  • Save ayrat555/2ffd1ea31178895db866e36d59bf26a3 to your computer and use it in GitHub Desktop.
Save ayrat555/2ffd1ea31178895db866e36d59bf26a3 to your computer and use it in GitHub Desktop.
let s = "* * 5-7 1,2,5 8 sudo rm -rf /";
assert_eq!(
CronItem::from_str(s).unwrap(),
CronItem {
minute: AllValues,
hour: AllValues,
day_of_month: Interval((5, 7)),
month: MultipleValues(vec![1, 2, 5]),
day_of_week: SingleValue(8),
command: String::from("sudo rm -rf /"),
}
);
let cron_item = CronItem {
minute: MultipleValues(vec![1, 10]),
hour: Interval((1, 4)),
day_of_month: Interval((1, 11)),
month: MultipleValues(vec![1, 2, 5]),
day_of_week: AllValues,
command: String::from("sudo rm -rf /"),
};
assert_eq!("1,10 1-4 1-11 1,2,5 * sudo rm -rf /", cron_item.to_string());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment