1use chrono::{Datelike, Local};
2
3pub enum GetType {
4 Today,
5 Date,
6 Month,
7 Year,
8}
9
10impl GetType {
11 fn clone(&self) -> GetType {
12 match self {
13 GetType::Today => GetType::Today,
14 GetType::Date => GetType::Date,
15 GetType::Month => GetType::Month,
16 GetType::Year => GetType::Year,
17 }
18 }
19}
20
21pub struct Config {
22 pub year: i32,
23 pub month: u32,
24 pub day: u32,
25 pub city: String,
26 pub country: String,
27 pub get_type: GetType,
28}
29
30impl Default for Config {
31 fn default() -> Self {
32 let today = Local::now().date_naive();
33 Self::new(today.year(), today.month(), today.day(), String::from("Maka"), String::from("SAU"), GetType::Month)
34 }
35}
36
37impl Config {
38 pub fn new(year: i32, month: u32, day: u32, city: String, country: String, get_type: GetType) -> Config {
39 Config {
40 year,
41 month,
42 day,
43 city,
44 country,
45 get_type,
46 }
47 }
48
49 pub fn clone(&self) -> Config {
50 Config {
51 year: self.year,
52 month: self.month,
53 day: self.day,
54 city: self.city.clone(),
55 country: self.country.clone(),
56 get_type: self.get_type.clone(),
57 }
58 }
59}