islam/salah/
method.rs

1use crate::salah::config::{Config, IshaInterval};
2
3#[derive(PartialEq, Debug, Copy, Clone)]
4pub enum Method {
5    /// University of Islamic Sciences, Karachi (UISK)
6    /// Ministry of Religious Affairs, Tunisia
7    /// France - Angle 18°
8    Karachi,
9
10    /// Muslim World League (MWL)
11    /// Ministry of Religious Affairs and Awqaf, Algeria
12    /// Presidency of Religious Affairs, Turkey
13    MuslimWorldLeague,
14
15    /// Egyptian General Authority of Survey (EGAS)
16    Egyptian,
17
18    /// Umm al-Qura University, Makkah (UMU)
19    UmmAlQura,
20
21    /// Islamic Society of North America (ISNA)
22    /// France - Angle 15°
23    NorthAmerica,
24
25    /// French Muslims (ex-UOIF)
26    French,
27
28    /// Islamic Religious Council of Singapore (MUIS)
29    /// Department of Islamic Advancements of Malaysia (JAKIM)
30    // Ministry of Religious Affairs of Indonesia (KEMENAG)
31    Singapore,
32
33    /// Spiritual Administration of Muslims of Russia
34    Russia,
35
36    /// Fixed Ishaa Time Interval, 90min
37    FixedInterval,
38}
39
40impl Method {
41    /// Generate configs
42    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}