1use serde::{Serialize, Deserialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
9pub struct PrayerParams {
10 pub fajr_angle: f64,
12 pub imsak_buffer_minutes: i64,
14 pub ihtiyat_minutes: i64,
16 pub rounding_granularity_seconds: i64,
18}
19
20impl Default for PrayerParams {
21 fn default() -> Self {
22 Self {
23 fajr_angle: -20.0,
24 imsak_buffer_minutes: 10,
25 ihtiyat_minutes: 2,
26 rounding_granularity_seconds: 60,
27 }
28 }
29}
30
31impl PrayerParams {
32 pub fn new(fajr_angle: f64, imsak_buffer_minutes: i64) -> Self {
34 Self {
35 fajr_angle,
36 imsak_buffer_minutes,
37 ihtiyat_minutes: 2,
38 rounding_granularity_seconds: 60,
39 }
40 }
41
42 pub fn with_ihtiyat(mut self, minutes: i64) -> Self {
44 self.ihtiyat_minutes = minutes;
45 self
46 }
47
48 pub fn with_rounding(mut self, seconds: i64) -> Self {
50 self.rounding_granularity_seconds = seconds;
51 self
52 }
53
54 pub fn mabims() -> Self { Self::default() }
56
57 pub fn egyptian() -> Self {
59 Self { fajr_angle: -19.5, imsak_buffer_minutes: 10, ihtiyat_minutes: 2, rounding_granularity_seconds: 60 }
60 }
61
62 pub fn mwl() -> Self {
64 Self { fajr_angle: -18.0, imsak_buffer_minutes: 10, ihtiyat_minutes: 2, rounding_granularity_seconds: 60 }
65 }
66
67 pub fn isna() -> Self {
69 Self { fajr_angle: -15.0, imsak_buffer_minutes: 10, ihtiyat_minutes: 2, rounding_granularity_seconds: 60 }
70 }
71
72 pub fn umm_al_qura() -> Self {
74 Self { fajr_angle: -18.5, imsak_buffer_minutes: 10, ihtiyat_minutes: 2, rounding_granularity_seconds: 60 }
75 }
76}