Struct HebrewYear

Source
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

Source

pub fn new(year: u64) -> Result<HebrewYear, ConversionError>

Returns a new HebrewYear on success or a ConversionError on failure.

§Arguments

year - The Hebrew year

Source

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);
Source

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

A MonthSchedule

Source

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);
Source

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.

Source

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);
Source

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

Source§

fn clone(&self) -> HebrewYear

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HebrewYear

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for HebrewYear

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.