18 releases (6 stable)

✓ Uses Rust 2018 edition

new 1.3.2 Jun 29, 2020
1.3.1 Jan 7, 2020
1.0.3 Dec 29, 2019
1.0.1 May 26, 2019
0.4.0 Mar 12, 2019

#10 in Date and time

Download history 19/week @ 2020-03-12 68/week @ 2020-03-19 17/week @ 2020-03-26 6/week @ 2020-04-02 82/week @ 2020-04-09 57/week @ 2020-04-16 6/week @ 2020-04-23 2/week @ 2020-04-30 2/week @ 2020-05-07 1/week @ 2020-05-14 3/week @ 2020-05-21 52/week @ 2020-05-28 18/week @ 2020-06-04 5/week @ 2020-06-11 1/week @ 2020-06-18 21/week @ 2020-06-25

79 downloads per month
Used in heca

MIT license

145KB
2K SLoC

Crates.io Documentation Build Status Average time to resolve an issue Percentage of issues still open License: MIT

heca-lib

heca-lib

heca-lib is a blazingly fast Hebrew calender library. It's the backend behind the heca program.

Usage:

  1. Add to Cargo.toml:
    [dependencies]
    heca-lib = "1.3"
  1. Import the types:
use heca_lib::prelude::*;
use heca_lib::*;

Overview:

Convert:

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:


extern crate heca_lib;

use chrono::Utc;
use chrono::offset::TimeZone;
use heca_lib::prelude::*;
use heca_lib::HebrewDate;

assert_eq!(HebrewDate::from_gregorian(Utc.ymd(2018,9,10).and_hms(17,59,59)).unwrap(),HebrewDate::from_ymd(5779,HebrewMonth::Tishrei,1).unwrap());

You can then get back a Gregorian date from this Hebrew Date.


extern crate heca_lib;

use chrono::Utc;
use chrono::offset::TimeZone;
use heca_lib::{HebrewDate};
use heca_lib::prelude::*;

assert_eq!(HebrewDate::from_ymd(5779,HebrewMonth::Tishrei,10).unwrap().to_gregorian(),Utc.ymd(2018, 9,18).and_hms(18,00,00));

Get Information on the Hebrew Year

This library can also list the major Jewish holidays and Torah readings in a given year (for both Israel and the Diaspora):


extern crate heca_lib;

use heca_lib::{HebrewYear,HebrewDate};
use heca_lib::prelude::*;

assert_eq!(HebrewYear::new(5779).unwrap().get_holidays(Location::Chul, &[TorahReadingType::Shabbos])[0].name(), TorahReading::Shabbos(Parsha::Vayelach));
assert_eq!(HebrewYear::new(5779).unwrap().get_holidays(Location::Chul, &[TorahReadingType::SpecialParsha]).iter().find(|x| x.name() == TorahReading::SpecialParsha(SpecialParsha::Zachor)).unwrap().day(),HebrewDate::from_ymd(5779,HebrewMonth::Adar2,9).unwrap());

Notes:

  1. This library won't work for years before 3764 (4).
  2. I tested this library against hebcal for all Rosh Hashanas between 3764 and 9999 (4-6239). I also checked it for all Rosh Chodesh Adars in those years. However, I take no resposibility if you accidently keep Yom Tov on the wrong day!

Current version: 1.3.1

License: MIT

Dependencies

~1.5–2.1MB
~43K SLoC