pub struct HebrewYear { /* private fields */ }Expand description
HebrewYear holds data on a given year. It’s faster to get multiple HebrewDates from an existing HebrewYear rather than generating each one on its own.
Implementations§
Source§impl HebrewYear
impl HebrewYear
Sourcepub fn new(year: u64) -> Result<HebrewYear, ConversionError>
pub fn new(year: u64) -> Result<HebrewYear, ConversionError>
Returns a new HebrewYear on success or a ConversionError on failure.
§Arguments
year - The Hebrew year
Sourcepub fn is_leap_year(&self) -> bool
pub fn is_leap_year(&self) -> bool
Returns if this year is a leap year.
use heca_lib::prelude::*;
use heca_lib::HebrewYear;
assert_eq!(HebrewYear::new(5779)?.is_leap_year(),true);Sourcepub fn year_type(&self) -> MonthSchedule
pub fn year_type(&self) -> MonthSchedule
Returns the type of year.
A Hebrew year can be one of 14 combinations of length and starting day.
§Returns
Sourcepub fn year(&self) -> u64
pub fn year(&self) -> u64
Returns the year.
§Examples:
use std::num::NonZeroI8;
use heca_lib::prelude::*;
use heca_lib::{HebrewDate, HebrewYear};
let year = HebrewYear::new(5779)?;
assert_eq!(year.year(), 5779);Sourcepub fn get_hebrew_date(
self,
month: HebrewMonth,
day: NonZeroI8,
) -> Result<HebrewDate, ConversionError>
pub fn get_hebrew_date( self, month: HebrewMonth, day: NonZeroI8, ) -> Result<HebrewDate, ConversionError>
Returns a HebrewDate from the current year and a supplied month and day.
§Arguments:
month - The Hebrew month.
day - The day of the Hebrew month.
§Examples:
use std::num::NonZeroI8;
use heca_lib::prelude::*;
use heca_lib::{HebrewDate, HebrewYear};
let year = HebrewYear::new(5779)?;
assert_eq!(
year.get_hebrew_date(HebrewMonth::Tishrei, NonZeroI8::new(10).unwrap())?,
HebrewDate::from_ymd(5779, HebrewMonth::Tishrei, NonZeroI8::new(10).unwrap())?
);§Notes:
Day must be above zero. If it’s below zero, the function returns TooManyDaysInMonth. In a future release, day will be a NonZeroU8 so that it will be impossible to supply a negative number.
Sourcepub fn get_holidays(
&self,
location: Location,
yt_types: &[TorahReadingType],
) -> SmallVec<[TorahReadingDay; 256]>
pub fn get_holidays( &self, location: Location, yt_types: &[TorahReadingType], ) -> SmallVec<[TorahReadingDay; 256]>
Returns all the days when the Torah is read.
§Arguments
location - Specify if you’re looking for the calendar in Israel or in the Diaspora. Is
relevent as there’s only one day of Yom Tov in Israel while there are two day of Yom Tov outside.
Since we don’t read the Weekly Parsha on Yom Tov, in a year when the 8th day of Pesach is on a Shabbos,
Israelis read the next Parsha while the Diaspora reads the Yom Tov Parsha, catching up in the summer.
yt_types - An array containing TorahReadingType. This should be used as a flag to
specify which types of Torah readings you want to list.
§Returns
Returns an array (or a vec) of days.
§Note
This may unsorted, and is returned under no defined order.
§Examples
use std::num::NonZeroI8;
use heca_lib::prelude::*;
use heca_lib::{HebrewDate, HebrewYear};
let year = HebrewYear::new(5779)?;
let shabbosim = year.get_holidays(Location::Chul, &[TorahReadingType::Shabbos, TorahReadingType::SpecialParsha, TorahReadingType::Chol, TorahReadingType::YomTov]);
let mut count = 0;
for s in shabbosim.into_iter() {
if s.name() == TorahReading::Shabbos(Parsha::Bereishis) {
assert_eq!(s.day(), HebrewDate::from_ymd(5779,HebrewMonth::Tishrei, NonZeroI8::new(27).unwrap())?);
count += 1;
}
else if s.name() == TorahReading::SpecialParsha(SpecialParsha::Zachor) {
assert_eq!(s.day(), HebrewDate::from_ymd(5779,HebrewMonth::Adar2, NonZeroI8::new(9).unwrap())?);
count += 1;
}
else if s.name() == TorahReading::Chol(Chol::Chanukah1) {
assert_eq!(s.day(), HebrewDate::from_ymd(5779,HebrewMonth::Kislev, NonZeroI8::new(25).unwrap())?);
count += 1;
}
else if s.name() == TorahReading::YomTov(YomTov::Shavuos1) {
assert_eq!(s.day(), HebrewDate::from_ymd(5779,HebrewMonth::Sivan, NonZeroI8::new(6).unwrap())?);
count += 1;
}
}
assert_eq!(count,4);Sourcepub fn get_molad(&self, month: HebrewMonth) -> Result<Molad, ConversionError>
pub fn get_molad(&self, month: HebrewMonth) -> Result<Molad, ConversionError>
Returns the Molad of a given month, or a ConversionError if trying to get Molad of a month which is does not exist in that year.
§Note:
The Molad has no modern Halachic significance since Rosh Chodesh isn’t derived from the Molad. However, it is useful to know as some say that one should know the Molad during the Birkas HaChodesh.
Trait Implementations§
Source§impl Clone for HebrewYear
impl Clone for HebrewYear
Source§fn clone(&self) -> HebrewYear
fn clone(&self) -> HebrewYear
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more