Crate rust_zmanim

Source
Expand description

§[WIP] rust-zmanim

Calculate different astronomical times including sunrise and sunset and Jewish zmanim or religious times for prayers and other Jewish religious duties.

The astronomical_calculator provides non-religious astronomical / solar calculations such as sunrise, sunset and twilight.

The zmanim_calculator contains the basics for zmanim calculations.

The complex_zmanim_calendar provides a stateful struct and many premade zmanim calculations, both merely conveniences built on the zmanim_calculator API.

This project is a port from pinnymz’s python-zmanim project and Eliyahu Hershfeld’s KosherJava project. Almost all of the code is from python-zmanim and KosherJava, and almost all of the documentation is from KosherJava

See the KosherJava site for additional information on the original Java project and zmanim in general.

Note: It is important to read the technical notes on top of the astronomical_calculator documentation.

§Disclaimer

I did my best to get accurate results using standardized astronomical calculations. Please use care when using the library for halacha lemaaseh applications.

§Example (more examples in /examples)

use rust_zmanim::prelude::*;

// the time in the DateTime will be ignored in zmanim calculations
let dt = chrono_tz::Asia::Jerusalem
    .with_ymd_and_hms(2025, 7, 29, 10, 30, 26)
    .unwrap();

// your location here
let beit_meir = GeoLocation {
    latitude: 31.7975,
    longitude: 35.0345,
    elevation: 526.0,
    timezone: chrono_tz::Asia::Jerusalem,
};

// the `zmanim_calculator` lets you make any custom tzais, alos, etc
if let Some(tzais_pi_degrees) = zmanim_calculator::tzais(
    &dt,
    &beit_meir,
    false,
    &ZmanOffset::Degrees(std::f64::consts::PI),
) {
    assert_eq!(
        format!("{tzais_pi_degrees}"),
        "2025-07-29 19:50:30.090272 IDT"
    );
}

// there is also a `ComplexZmanimCalendar` struct which stores the date and
// location, convenient for getting many zmanim for the same point in 4D space.
// It also has many common zmanim pre-made
let czc = ComplexZmanimCalendar {
    geo_location: beit_meir,
    date: dt,
    use_elevation: UseElevation::No,
};

if let Some(alos120) = czc.alos_120_minutes() {
    assert_eq!(format!("{alos120}"), "2025-07-29 03:53:39.574573 IDT");
};

if let Some(sz18) = czc.shaah_zmanis_18_degrees() {
    // 01:24:14.1060605 in minutes
    assert_eq!(sz18, 84.23510100833333);
}

// the calculations will return `None` if the specified solar event will not
// occur
let north_pole = GeoLocation {
    latitude: 90.0,
    longitude: 0.0,
    elevation: 0.0,
    timezone: chrono_tz::UTC,
};
let polar_sunset = zmanim_calculator::shkia(&dt, &north_pole, false);
assert!(polar_sunset.is_none());

Modules§

astronomical_calculator
An API that calculates astronomical times such as sunrise, sunset and twilight times.
complex_zmanim_calendar
The ComplexZmanimCalendar struct is stateful and has many premade zmanim calculations, both conveniences built on the zmanim_calculator API.
prelude
A convenience module for glob imports. use rust_zmanim::prelude::*;
util
Utility modules for the Zmanim API.
zmanim_calculator
An API that can calculate sunrise, sunset and Jewish zmanim (religious times) for prayers and other Jewish religious duties.