umya_spreadsheet/structs/
time_period_values.rs1use super::EnumTrait;
2use std::str::FromStr;
3#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
4pub enum TimePeriodValues {
5 Last7Days,
6 LastMonth,
7 LastWeek,
8 NextMonth,
9 NextWeek,
10 ThisMonth,
11 ThisWeek,
12 Today,
13 Tomorrow,
14 Yesterday,
15}
16impl Default for TimePeriodValues {
17 #[inline]
18 fn default() -> Self {
19 Self::Today
20 }
21}
22impl EnumTrait for TimePeriodValues {
23 #[inline]
24 fn get_value_string(&self) -> &str {
25 match &self {
26 Self::Last7Days => "last7Days",
27 Self::LastMonth => "lastMonth",
28 Self::LastWeek => "lastWeek",
29 Self::NextMonth => "nextMonth",
30 Self::NextWeek => "nextWeek",
31 Self::ThisMonth => "thisMonth",
32 Self::ThisWeek => "thisWeek",
33 Self::Today => "today",
34 Self::Tomorrow => "tomorrow",
35 Self::Yesterday => "yesterday",
36 }
37 }
38}
39impl FromStr for TimePeriodValues {
40 type Err = ();
41
42 #[inline]
43 fn from_str(input: &str) -> Result<Self, Self::Err> {
44 match input {
45 "last7Days" => Ok(Self::Last7Days),
46 "lastMonth" => Ok(Self::LastMonth),
47 "lastWeek" => Ok(Self::LastWeek),
48 "nextMonth" => Ok(Self::NextMonth),
49 "nextWeek" => Ok(Self::NextWeek),
50 "thisMonth" => Ok(Self::ThisMonth),
51 "thisWeek" => Ok(Self::ThisWeek),
52 "today" => Ok(Self::Today),
53 "tomorrow" => Ok(Self::Tomorrow),
54 "yesterday" => Ok(Self::Yesterday),
55 _ => Err(()),
56 }
57 }
58}