rust_zmanim/complex_zmanim_calendar/
czc_macros.rs1#[macro_export]
2macro_rules! zmanim_for_offset {
3 ($name:ident, $offset_fn:expr, [$($method:ident => $doc:expr),* $(,)?]) => {
5 $(
6 zmanim_for_offset!(@method_custom $name, $offset_fn, $method, $doc);
7 )*
8 };
9
10 (@method_custom $name:ident, $offset_fn:expr, alos, $doc:expr) => {
12 paste! {
13 #[must_use]
14 #[doc = $doc]
15 pub fn [<alos $name>](&self) -> Option<DateTime<Tz>> {
16 let offset = ($offset_fn)(self)?;
17 self.alos(&offset)
18 }
19 }
20 };
21
22 (@method_custom $name:ident, $offset_fn:expr, tzais, $doc:expr) => {
24 paste! {
25 #[must_use]
26 #[doc = $doc]
27 pub fn [<tzais $name>](&self) -> Option<DateTime<Tz>> {
28 let offset = ($offset_fn)(self)?;
29 self.tzais(&offset)
30 }
31 }
32 };
33
34 (@method_custom $name:ident, $offset_fn:expr, shaah_zmanis_mga, $doc:expr) => {
36 paste! {
37 #[must_use]
38 #[doc = $doc]
39 pub fn [<shaah_zmanis_mga $name>](&self) -> Option<TimeDelta> {
40 let offset = ($offset_fn)(self)?;
41 self.shaah_zmanis_mga(&offset)
42 }
43 }
44 };
45
46 (@method_custom $name:ident, $offset_fn:expr, sof_zman_shema_mga, $doc:expr) => {
48 paste! {
49 #[must_use]
50 #[doc = $doc]
51 pub fn [<sof_zman_shema_mga $name>](&self) -> Option<DateTime<Tz>> {
52 let offset = ($offset_fn)(self)?;
53 self.sof_zman_shema_mga(&offset)
54 }
55 }
56 };
57
58 (@method_custom $name:ident, $offset_fn:expr, sof_zman_tefila_mga, $doc:expr) => {
60 paste! {
61 #[must_use]
62 #[doc = $doc]
63 pub fn [<sof_zman_tefila_mga $name>](&self) -> Option<DateTime<Tz>> {
64 let offset = ($offset_fn)(self)?;
65 self.sof_zman_tefila_mga(&offset)
66 }
67 }
68 };
69
70 (@method_custom $name:ident, $offset_fn:expr, sof_zman_biur_chametz_mga, $doc:expr) => {
72 paste! {
73 #[must_use]
74 #[doc = $doc]
75 pub fn [<sof_zman_biur_chametz_mga $name>](&self) -> Option<DateTime<Tz>> {
76 let offset = ($offset_fn)(self)?;
77 self.sof_zman_biur_chametz_mga(&offset)
78 }
79 }
80 };
81
82 (@method_custom $name:ident, $offset_fn:expr, mincha_gedola_mga, $doc:expr) => {
84 paste! {
85 #[must_use]
86 #[doc = $doc]
87 pub fn [<mincha_gedola_mga $name>](&self) -> Option<DateTime<Tz>> {
88 let offset = ($offset_fn)(self)?;
89 self.mincha_gedola_mga(&offset)
90 }
91 }
92 };
93
94 (@method_custom $name:ident, $offset_fn:expr, samuch_lemincha_ketana_mga, $doc:expr) => {
96 paste! {
97 #[must_use]
98 #[doc = $doc]
99 pub fn [<samuch_lemincha_ketana_mga $name>](&self) -> Option<DateTime<Tz>> {
100 let offset = ($offset_fn)(self)?;
101 self.samuch_lemincha_ketana_mga(&offset)
102 }
103 }
104 };
105
106 (@method_custom $name:ident, $offset_fn:expr, mincha_ketana_mga, $doc:expr) => {
108 paste! {
109 #[must_use]
110 #[doc = $doc]
111 pub fn [<mincha_ketana_mga $name>](&self) -> Option<DateTime<Tz>> {
112 let offset = ($offset_fn)(self)?;
113 self.mincha_ketana_mga(&offset)
114 }
115 }
116 };
117
118 (@method_custom $name:ident, $offset_fn:expr, plag_mga, $doc:expr) => {
120 paste! {
121 #[must_use]
122 #[doc = $doc]
123 pub fn [<plag_mga $name>](&self) -> Option<DateTime<Tz>> {
124 let offset = ($offset_fn)(self)?;
125 self.plag_mga(&offset)
126 }
127 }
128 };
129}