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
|
use chrono::Weekday;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum Repetition {
Daily { frequency: u8 },
Monthly { frequency: MonthFrequency },
Yearly,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum MonthFrequency {
Day { day: u8 },
FirstDay { day: Weekday },
}
// Validation
pub fn validate_day(str: &str) -> Option<u8> {
let n = str.parse::<u8>().ok()?;
if n >= 1 && n <= 31 {
Some(n)
} else {
None
}
}
|