heca-lib is a blazingly fast Hebrew calender library. It's the backend behind the heca program.
toml
[dependencies]
heca-lib = "1.3"
rust
use heca_lib::prelude::*;
use heca_lib::*;
This library can convert from Hebrew to Gregorian dates and back. You can get a HebrewDate either from a known Hebrew date or from a Gregorian date:
```rust
extern crate heca_lib;
use chrono::Utc; use chrono::offset::TimeZone; use hecalib::prelude::*; use hecalib::HebrewDate;
asserteq!(HebrewDate::fromgregorian(Utc.ymd(2018,9,10).andhms(17,59,59)).unwrap(),HebrewDate::fromymd(5779,HebrewMonth::Tishrei,1).unwrap());
```
You can then get back a Gregorian date from this Hebrew Date.
```rust
extern crate heca_lib;
use chrono::Utc; use chrono::offset::TimeZone; use hecalib::{HebrewDate}; use hecalib::prelude::*;
asserteq!(HebrewDate::fromymd(5779,HebrewMonth::Tishrei,10).unwrap().togregorian(),Utc.ymd(2018, 9,18).andhms(18,00,00));
```
This library can also list the major Jewish holidays and Torah readings in a given year (for both Israel and the Diaspora):
```rust
extern crate heca_lib;
use hecalib::{HebrewYear,HebrewDate}; use hecalib::prelude::*;
asserteq!(HebrewYear::new(5779).unwrap().getholidays(Location::Chul, &[TorahReadingType::Shabbos])[0].name(), TorahReading::Shabbos(Parsha::Vayelach)); asserteq!(HebrewYear::new(5779).unwrap().getholidays(Location::Chul, &[TorahReadingType::SpecialParsha]).iter().find(|x| x.name() == TorahReading::SpecialParsha(SpecialParsha::Zachor)).unwrap().day(),HebrewDate::from_ymd(5779,HebrewMonth::Adar2,9).unwrap());
```
Current version: 1.3.1
License: MIT