[−][src]Struct heca_lib::HebrewYear
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
impl HebrewYear
[src]
pub fn new(year: u64) -> Result<HebrewYear, ConversionError>
[src]
Returns a new HebrewYear on success or a ConversionError on failure.
Arguments
year
- The Hebrew year
pub fn is_leap_year(&self) -> bool
[src]
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);
pub fn year_type(&self) -> MonthSchedule
[src]
Returns the type of year.
A Hebrew year can be one of 14 combinations of length and starting day.
Returns
pub fn year(&self) -> u64
[src]
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);
pub fn get_hebrew_date(
self,
month: HebrewMonth,
day: NonZeroI8
) -> Result<HebrewDate, ConversionError>
[src]
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.
pub fn get_holidays(
&self,
location: Location,
yt_types: &[TorahReadingType]
) -> SmallVec<[TorahReadingDay; 256]>
[src]
&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);
pub fn get_molad(&self, month: HebrewMonth) -> Result<Molad, ConversionError>
[src]
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
impl Clone for HebrewYear
[src]
fn clone(&self) -> HebrewYear
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for HebrewYear
[src]
impl Debug for HebrewYear
[src]
Auto Trait Implementations
impl RefUnwindSafe for HebrewYear
impl Send for HebrewYear
impl Sync for HebrewYear
impl Unpin for HebrewYear
impl UnwindSafe for HebrewYear
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,