heca-lib is a Hebrew <-> Gregorian converter library. It's the backend behind the heca program.
Add to Cargo.toml:
[dependencies] heca-lib = "*"
Add the following to your crate root:
extern crate heca_lib;
Import the types:
use heca_lib::*;
This library converts 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::{HebrewDate,HebrewMonth};
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,HebrewMonth};
assert_eq!(HebrewDate::from_ymd(5779,HebrewMonth::Tishrei,10).unwrap().to_gregorian(),Utc.ymd(2018, 9,18).and_hms(18,00,00));
MIT