README/
README.rs

1use chrono::TimeDelta;
2use rust_zmanim::prelude::*;
3
4fn main() {
5    // the time in the DateTime will be ignored in zmanim calculations
6    let dt = chrono_tz::Asia::Jerusalem
7        .with_ymd_and_hms(2025, 7, 29, 10, 30, 26)
8        .unwrap();
9
10    // your location here
11    let beit_meir = GeoLocation {
12        latitude: 31.7975,
13        longitude: 35.0345,
14        elevation: 526.0,
15        timezone: chrono_tz::Asia::Jerusalem,
16    };
17
18    // the `zmanim_calculator` lets you make any custom tzais, alos, etc
19    if let Some(tzais_pi_degrees) = zmanim_calculator::tzais(
20        &dt,
21        &beit_meir,
22        false,
23        &ZmanOffset::Degrees(std::f64::consts::PI),
24    ) {
25        assert_eq!(
26            tzais_pi_degrees.to_string(),
27            "2025-07-29 19:50:30.090272127 IDT"
28        );
29    }
30
31    // there is also a `ComplexZmanimCalendar` struct which stores the date and
32    // location, convenient for getting many zmanim for the same point in 4D space.
33    // It also has many common zmanim pre-made
34    let czc = ComplexZmanimCalendar {
35        geo_location: &beit_meir,
36        date: &dt,
37        use_elevation: UseElevation::No,
38    };
39
40    if let Some(alos120) = czc.alos_120_minutes() {
41        assert_eq!(alos120.to_string(), "2025-07-29 03:53:39.574572512 IDT");
42    };
43
44    if let Some(sz18) = czc.shaah_zmanis_18_degrees() {
45        // 01:24:14.106060472
46        assert_eq!(sz18, TimeDelta::nanoseconds(5054106060472));
47    }
48
49    // the calculations will return `None` if the specified solar event will not
50    // occur
51    let north_pole = GeoLocation {
52        latitude: 90.0,
53        longitude: 0.0,
54        elevation: 0.0,
55        timezone: chrono_tz::UTC,
56    };
57    let polar_sunset = zmanim_calculator::shkia(&dt, &north_pole, false);
58    assert!(polar_sunset.is_none());
59}