rust-zmanim
Fast, reliable Rust APIs for sunrise/sunset and Jewish zmanim calculations from any date and location.
rust-zmanim calculates:
- astronomical times such as sunrise, sunset, solar noon, and twilight
- Jewish zmanim for prayers and other halachic time-based use cases
Astronomical events are calculated using the Jean Meeus algorithm.
rust-zmanim is ported from python-zmanim and KosherJava zmanim
Quick Start
rust-zmanim is on crates.io. Add it to your project via Cargo.toml or by running cargo add rust-zmanim.
jiff is also required, as all times, dates, and durations are represented using jiff types.
Example Usage
use ;
use *;
let date = now.date;
let location = GeoLocation ;
let czc = ComplexZmanimCalendar ;
println!;
println!;
Most functions return Option<Zoned>. None is returned when a solar event does not occur for the given date and location — for example, near the poles during parts of summer or winter, or when requesting a dawn/nightfall angle the sun never reaches.
API Overview
astronomical_calculator: for low-level solar/astronomical calculationszmanim_calculator: for stateless zmanim calculation functions (you passdateandGeoLocationeach call)ComplexZmanimCalendar: stateful struct for calculating multiple zmanim for a single date and location, with built-in methods covering both common and uncommon zmanim
Usage
1. One-Off Calculations with zmanim_calculator
use ;
use *;
let date = now.date;
let location = GeoLocation ;
let hanetz = hanetz.unwrap;
let shkia = shkia.unwrap;
println!;
println!;
let sof_shema_gra = sof_zman_shema;
println!;
println!;
2. Custom Offsets
use ;
use *;
let date = now.date;
let location = GeoLocation ;
let tzeis_4_5 =
tzeis.unwrap;
println!;
let alos_72 =
alos.unwrap;
println!;
// this is much easier with ComplexZmanimCalendar - see next example
let hanetz = hanetz.unwrap;
let shkia = shkia.unwrap;
let shaah_zmanis = shaah_zmanis;
let tzeis_90_zmanis = tzeis
.unwrap;
println!;
3. Using ComplexZmanimCalendar
use ;
use *;
let date = now.date;
let location = GeoLocation ;
let czc = ComplexZmanimCalendar ;
let tzeis_4_5 = czc.tzeis.unwrap;
println!;
let alos_72 = czc.alos_72_minutes.unwrap;
println!;
let tzeis_90_zmanis = czc.tzeis_90_minutes_zmanis.unwrap;
println!;
Elevation Handling
ComplexZmanimCalendar has a use_elevation setting that controls when elevation adjustments apply.
UseElevation::No: sea-level based zmanimUseElevation::HanetzShkia: elevation for sunrise/sunset onlyUseElevation::All: elevation applied broadly
zmanim_calculator functions take a bool for whether they should use elevation
See module docs for halachic discussion and caveats.
Accuracy and Limitations
Results are mathematically precise within the bounds of the underlying model. Observed real-world times may differ due to atmospheric conditions such as pressure, temperature, and refraction. As NOAA notes, calculated and observed values can vary.
Exercise appropriate caution when applying these results to practical halachic decisions.
Further Reading
See runnable examples in examples/