aboutsummaryrefslogtreecommitdiff
path: root/karlcommon/src/misc.rs
blob: 4d181ba2bf11a6c0372bc44de77a36be309e7541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::{Property, Task};

impl Property {
    pub const VALUES: &'static [Property] = &[
        Property::Year,
        Property::Monthofyear,
        Property::Weekofmonth,
        Property::Dayofyear,
        Property::Dayofmonth,
        Property::Dayofweek,
        Property::Hour,
        Property::Minute,
        Property::Second,
        Property::Unix,
    ];
    pub fn to_str(self) -> &'static str {
        match self {
            Property::Year => "Year",
            Property::Monthofyear => "Month of the year",
            Property::Weekofmonth => "Week of the month",
            Property::Dayofyear => "Day of the year",
            Property::Dayofmonth => "Day of the month",
            Property::Dayofweek => "Day of the week",
            Property::Hour => "Hour",
            Property::Minute => "Minute",
            Property::Second => "Second",
            Property::Unix => "Unix timestamp",
        }
    }
}

impl Task {
    pub fn default_with_id(id: u64) -> Self {
        Self {
            id,
            name: Default::default(),
            description: Default::default(),
            tags: Default::default(),
            schedule: crate::Schedule::Never,
        }
    }
}