1use crate::salah::config::{Config, IshaInterval};
2
3#[derive(PartialEq, Debug, Copy, Clone)]
4pub enum Method {
5 Karachi,
9
10 MuslimWorldLeague,
14
15 Egyptian,
17
18 UmmAlQura,
20
21 NorthAmerica,
24
25 French,
27
28 Singapore,
32
33 Russia,
35
36 FixedInterval,
38}
39
40impl Method {
41 pub fn configs(self) -> Config {
43 match self {
44 Self::Karachi => Config::new().angle(18.0, 18.0).method(self),
45 Self::MuslimWorldLeague => Config::new().angle(18.0, 17.0).method(self),
46 Self::Egyptian => Config::new().angle(19.5, 17.5).method(self),
47 Self::UmmAlQura => {
48 Config::new()
49 .angle(18.5, 0.0)
50 .method(self)
51 .isha_interval(IshaInterval {
52 all_year: 90.0,
53 ramdan: 120.0,
54 })
55 }
56 Self::NorthAmerica => Config::new().angle(15.0, 15.0).method(self),
57 Self::French => Config::new().angle(12.0, 12.0).method(self),
58 Self::Singapore => Config::new().angle(20.0, 18.0).method(self),
59 Self::Russia => Config::new().angle(16.0, 15.0).method(self),
60 Self::FixedInterval => {
61 Config::new()
62 .angle(19.5, 0.0)
63 .method(self)
64 .isha_interval(IshaInterval {
65 all_year: 90.0,
66 ramdan: 120.0,
67 })
68 }
69 }
70 }
71}
72
73#[cfg(test)]
74mod tests {
75 use super::*;
76
77 #[test]
78 fn configs_for_muslim_world_league() {
79 let method = Method::MuslimWorldLeague;
80 let params = method.configs();
81
82 assert_eq!(params.method, Method::MuslimWorldLeague);
83 }
84
85 #[test]
86 fn configs_for_egyptian() {
87 let method = Method::Egyptian;
88 let params = method.configs();
89
90 assert_eq!(params.method, Method::Egyptian);
91 }
92}