1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see:
// <https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>
//! # rust-zmanim
//! `rust-zmanim` calculates solar events (such as sunrise, sunset, and
//! twilight) and Jewish *zmanim* built on those events.
//!
//! ## Modules
//! - [`astronomical_calculator`]: Low-level astronomical calculations.
//! - [`zmanim_calculator`]: Core *zmanim* building blocks.
//! - [`complex_zmanim_calendar`]: Stateful convenience API with many predefined
//! *zmanim*.
//!
//! ## Examples
//!
//! ### `zmanim_calculator`: [*Hanetz*](zmanim_calculator::hanetz) (sunrise)
//! ```rust
//! use jiff::{tz::TimeZone, Zoned};
//! use rust_zmanim::prelude::*;
//!
//! let date = Zoned::now().date();
//! let location = GeoLocation {
//! latitude: 31.778,
//! longitude: 35.234,
//! elevation: 754.0,
//! timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! };
//!
//! let hanetz = zmanim_calculator::hanetz(&date, &location, false).unwrap();
//! println!("Hanetz: {}", hanetz.strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `zmanim_calculator`: [*Shkia*](zmanim_calculator::shkia) (sunset)
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! let shkia = zmanim_calculator::shkia(&date, &location, false).unwrap();
//! println!("Shkia: {}", shkia.strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `zmanim_calculator`: [*Chatzos*](zmanim_calculator::chatzos) (Solar Noon)
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! let chatzos = zmanim_calculator::chatzos(&date, &location).unwrap();
//! println!("Chatzos: {}", chatzos.strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `zmanim_calculator`: [*Alos*](zmanim_calculator::alos) with a Minutes Offset
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! let alos_72 =
//! zmanim_calculator::alos(&date, &location, false, &ZmanOffset::Minutes(72.0)).unwrap();
//! println!("Alos (72 min): {}", alos_72.strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `zmanim_calculator`: [*Tzeis*](zmanim_calculator::tzeis) with a Degrees Offset
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! let tzeis_4_5 =
//! zmanim_calculator::tzeis(&date, &location, false, &ZmanOffset::Degrees(4.5)).unwrap();
//! println!("Tzeis (4.5 deg): {}", tzeis_4_5.strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `zmanim_calculator`: [*Sof Zman Shema*](zmanim_calculator::sof_zman_shema) (MGA) using *zmanis*-based *Alos* and *Tzeis*
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! let hanetz = zmanim_calculator::hanetz(&date, &location, false).unwrap();
//! let shkia = zmanim_calculator::shkia(&date, &location, false).unwrap();
//! // this is a GRA shaah zmanis, based on sunrise and sunset
//! let shaah_zmanis_gra = zmanim_calculator::shaah_zmanis(&hanetz, &shkia);
//!
//! // the offset used for alos and tzeis will be based on shaos zmaniyos
//! let offset_50_zmanis = ZmanOffset::MinutesZmaniyos {
//! minutes_zmaniyos: 50.0,
//! shaah_zmanis: shaah_zmanis_gra,
//! };
//! let alos_50_zmanis =
//! zmanim_calculator::alos(&date, &location, false, &offset_50_zmanis).unwrap();
//! let tzeis_50_zmanis =
//! zmanim_calculator::tzeis(&date, &location, false, &offset_50_zmanis).unwrap();
//!
//! // calculate Sof Zman Shema according to the Magen Avraham, that it is
//! // calculated from alos to tzeis
//! let szks = zmanim_calculator::sof_zman_shema(&alos_50_zmanis, &tzeis_50_zmanis);
//! println!(
//! "Sof Zman Shema (MGA 50 min zmaniyos): {}",
//! szks.strftime("%H:%M:%S %Z")
//! );
//! ```
//!
//! ### [`ComplexZmanimCalendar`](complex_zmanim_calendar::ComplexZmanimCalendar): Build Once, Reuse Many Times
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! let czc = ComplexZmanimCalendar {
//! geo_location: location,
//! date,
//! use_elevation: UseElevation::No,
//! };
//!
//! println!("Hanetz: {}", czc.hanetz().unwrap().strftime("%H:%M:%S %Z"));
//! println!("Shkia: {}", czc.shkia().unwrap().strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `ComplexZmanimCalendar`: Premade [72-Minute *Alos*](complex_zmanim_calendar::ComplexZmanimCalendar::alos_72_minutes)
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! # let czc = ComplexZmanimCalendar {
//! # geo_location: location,
//! # date,
//! # use_elevation: UseElevation::No,
//! # };
//! #
//! println!("Alos (72 min): {}", czc.alos_72_minutes().unwrap().strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `ComplexZmanimCalendar`: [Generic *Tzeis*](complex_zmanim_calendar::ComplexZmanimCalendar::tzeis) with Custom Offset
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! # let czc = ComplexZmanimCalendar {
//! # geo_location: location,
//! # date,
//! # use_elevation: UseElevation::No,
//! # };
//! #
//! let tzeis_7_083 = czc.tzeis(&ZmanOffset::Degrees(7.083)).unwrap();
//! println!("Tzeis (7.083 deg): {}", tzeis_7_083.strftime("%H:%M:%S %Z"));
//! ```
//!
//! ### `ComplexZmanimCalendar`: [*Tzeis* 90 Minutes *Zmaniyos* After Sunset](complex_zmanim_calendar::ComplexZmanimCalendar::tzeis_90_minutes_zmanis)
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! # let czc = ComplexZmanimCalendar {
//! # geo_location: location,
//! # date,
//! # use_elevation: UseElevation::No,
//! # };
//! #
//! let tzeis_90_zmanis = czc.tzeis_90_minutes_zmanis().unwrap();
//! println!(
//! "Tzeis (90 min zmaniyos): {}",
//! tzeis_90_zmanis.strftime("%H:%M:%S %Z")
//! );
//! ```
//!
//! ### `ComplexZmanimCalendar`: [Elevation Modes](complex_zmanim_calendar::UseElevation)
//! ```rust
//! # use jiff::{tz::TimeZone, Zoned};
//! # use rust_zmanim::prelude::*;
//! #
//! # let date = Zoned::now().date();
//! # let location = GeoLocation {
//! # latitude: 31.778,
//! # longitude: 35.234,
//! # elevation: 754.0,
//! # timezone: TimeZone::get("Asia/Jerusalem").unwrap(),
//! # };
//! #
//! let sea_level = ComplexZmanimCalendar {
//! geo_location: location.clone(),
//! date,
//! use_elevation: UseElevation::No,
//! };
//!
//! let elevated = ComplexZmanimCalendar {
//! geo_location: location,
//! date,
//! use_elevation: UseElevation::HanetzShkia,
//! };
//!
//! let sea_level_hanetz = sea_level.hanetz().unwrap();
//! let elevated_hanetz = elevated.hanetz().unwrap();
//! println!("Sea-level hanetz: {}", sea_level_hanetz.strftime("%H:%M:%S %Z"));
//! println!("Elevated hanetz: {}", elevated_hanetz.strftime("%H:%M:%S %Z"));
//! ```
//!
//! ## Notes
//! - Most APIs return `Option<Zoned>`. A result of `None` means the requested
//! event does not occur for the requested date/location (common in high
//! latitudes or for deep-twilight calculations).
//! - This crate uses NOAA-based algorithms. Returned values can be highly
//! precise, but real-world observations vary with atmospheric conditions,
//! temperature, pressure, etc.
//! - For religious practice (*halacha lemaaseh*), **consult competent halachic
//! guidance**.
//! - **Elevation based *zmanim* (even sunrise and sunset) should not be used
//! *lekula* without the guidance of a *posek***. According to Rabbi Dovid
//! Yehudah Bursztyn in his *Zmanim Kehilchasam*, 7th edition chapter 2,
//! section 7 (pages 181-182) and section 9 (pages 186-187), no *zmanim*
//! besides sunrise and sunset should use elevation. However, Rabbi Yechiel
//! Avrahom Zilber in the *Birur Halacha* Vol. 6 Ch. 58 Pages 34 and 42 is of
//! the opinion that elevation should be accounted for in *zmanim*
//! calculations. Related to this, Rabbi Yaakov Karp in *Shimush Zekeinim*,
//! Ch. 1, page 17 states that obstructing horizons should be factored into
//! *zmanim* calculations.
//!
//! ## Background
//! This crate is a Rust port which reuses a lot of code and documentation from:
//! - [KosherJava](https://github.com/KosherJava/zmanim)
//! - [python-zmanim](https://github.com/pinnymz/python-zmanim)
//!
//! See the [KosherJava website](https://kosherjava.com) for additional
//! background on *zmanim*.
/// A convenience module for glob imports. `use rust_zmanim::prelude::*;`