pub struct CronExpr {
pub seconds: Option<CronField>,
pub minutes: CronField,
pub hours: CronField,
pub dom: CronField,
pub month: CronField,
pub dow: CronField,
}Expand description
A parsed cron expression (5-field or 6-field with seconds).
§Example
use tpt_cron_parse::CronExpr;
let expr = CronExpr::parse("0 9 * * 1").unwrap();
assert_eq!(expr.to_human_readable(), "Every Monday at 9:00 AM");Fields§
§seconds: Option<CronField>Seconds field — Some for 6-field cron, None for 5-field.
minutes: CronFieldMinutes field.
hours: CronFieldHours field.
dom: CronFieldDay-of-month field.
month: CronFieldMonth field.
dow: CronFieldDay-of-week field.
Implementations§
Source§impl CronExpr
impl CronExpr
Sourcepub fn parse(s: &str) -> Result<CronExpr, CronError>
pub fn parse(s: &str) -> Result<CronExpr, CronError>
Parse a cron expression string (5-field or 6-field).
§Example
use tpt_cron_parse::CronExpr;
let expr = CronExpr::parse("*/5 * * * *").unwrap();
assert_eq!(expr.to_human_readable(), "Every 5 minutes");Sourcepub fn is_6_field(&self) -> bool
pub fn is_6_field(&self) -> bool
Returns true if this is a 6-field cron expression (with seconds).
Sourcepub fn to_human_readable(&self) -> String
pub fn to_human_readable(&self) -> String
Convert this cron expression to a human-readable English description.
§Example
use tpt_cron_parse::CronExpr;
assert_eq!(CronExpr::parse("* * * * *").unwrap().to_human_readable(), "Every minute");
assert_eq!(CronExpr::parse("0 * * * *").unwrap().to_human_readable(), "Every hour");
assert_eq!(CronExpr::parse("0 9 * * *").unwrap().to_human_readable(), "Every day at 9:00 AM");
assert_eq!(CronExpr::parse("0 0 1 1 *").unwrap().to_human_readable(), "At 12:00 AM on January 1st");Trait Implementations§
impl Eq for CronExpr
impl StructuralPartialEq for CronExpr
Auto Trait Implementations§
impl Freeze for CronExpr
impl RefUnwindSafe for CronExpr
impl Send for CronExpr
impl Sync for CronExpr
impl Unpin for CronExpr
impl UnsafeUnpin for CronExpr
impl UnwindSafe for CronExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more