clockwork_cron/time_unit/
hours.rs

1use crate::ordinal::{Ordinal, OrdinalSet};
2use crate::time_unit::TimeUnitField;
3use std::borrow::Cow;
4
5#[derive(Clone, Debug, Eq)]
6pub struct Hours {
7    ordinals: Option<OrdinalSet>,
8}
9
10impl TimeUnitField for Hours {
11    fn from_optional_ordinal_set(ordinal_set: Option<OrdinalSet>) -> Self {
12        Hours {
13            ordinals: ordinal_set,
14        }
15    }
16    fn name() -> Cow<'static, str> {
17        Cow::from("Hours")
18    }
19    fn inclusive_min() -> Ordinal {
20        0
21    }
22    fn inclusive_max() -> Ordinal {
23        23
24    }
25    fn ordinals(&self) -> OrdinalSet {
26        match self.ordinals.clone() {
27            Some(ordinal_set) => ordinal_set,
28            None => Hours::supported_ordinals(),
29        }
30    }
31}
32
33impl PartialEq for Hours {
34    fn eq(&self, other: &Hours) -> bool {
35        self.ordinals() == other.ordinals()
36    }
37}