Enum MonthSchedule

Source
pub enum MonthSchedule {
Show 14 variants BaChaG, BaShaH, GaChaH, HaKaZ, HaShA, ZaChA, ZaShaG, BaChaH, BaShaZ, GaKaZ, HaChA, HaShaG, ZaChaG, ZaShaH,
}
Expand description

A Hebrew year can be defined by three variables:

  1. The first day of Rosh Hashana - Monday (the second day of the week, represented by Beis - Ba), Tuesday (the third day of the week, represented by Gimmel - Ga), Thursday (the fifth day of the week, represented by Hei - Ha) and Shabbos (the seventh day of the week, represented by Zayin - Za).
  2. The length of the year, specifically, if Cheshvan and Kislev are both full (Sheleima - 30 days long), empty (Chaseir - 29 days long), or in regular order (“Kesidra”, Cheshvan is 29 days long and Kislev is 30. So the year goes 30,29,30,29 etc.).
  3. The day Pesach starts, defined as on Rosh Hashana above.

So, for example, 5779 is a BaShaZ year - that is, the first day of Rosh Hashana was on a Monday (Beis - Ba), Bosh Cheshvan and Kislev are full (Shleimah - Shin), and the first night of Pesach was on Friday night (Zain - Z for Shabbos).

§Examples


use heca_lib::HebrewYear;
use heca_lib::prelude::*;
assert_eq!(HebrewYear::new(5779)?.year_type(),MonthSchedule::BaShaZ);

§Find out how often does Pesach start on which days:


use heca_lib::HebrewYear;
use heca_lib::prelude::*;
let (mut thu, mut tue, mut sun, mut sat) = (0,0,0,0);
for year in 3765..9999 {
    let t = HebrewYear::new(year)?.year_type();
    match t {
        MonthSchedule::GaChaH
        | MonthSchedule::BaShaH
        | MonthSchedule::BaChaH
        | MonthSchedule::ZaShaH => thu += 1,

        MonthSchedule::HaShaG
        | MonthSchedule::ZaShaG
        | MonthSchedule::ZaChaG
        | MonthSchedule::BaChaG => tue += 1,

        MonthSchedule::HaShA
        | MonthSchedule::ZaChA
        | MonthSchedule::HaChA => sun += 1,
         
        MonthSchedule::HaKaZ
        | MonthSchedule::BaShaZ
        | MonthSchedule::GaKaZ => sat += 1,
    }
}
assert_eq!(thu, 1782);
assert_eq!(tue, 1988);
assert_eq!(sun, 718); // <-- Note, that Pesach falls out on a Motzei Shabbos only 10% of the time.
assert_eq!(sat, 1746);

§Find out when will Pesach start on Motzei Shabbos:

use heca_lib::HebrewYear;
use heca_lib::prelude::*;
let mut years: Vec<u64> = Vec::new();
for year in 5780..5880 {
    let t = HebrewYear::new(year).unwrap().year_type();
    match t {
        MonthSchedule::HaShA
        | MonthSchedule::ZaChA
        | MonthSchedule::HaChA => years.push(year),

        _ => { }
         
    }
}
assert_eq!(years, vec![5781, 5785, 5805, 5808, 5812, 5832, 5835, 5839, 5859, 5863] ); // <-- We'll have two of them over the next few years, and then Pesach won't fall out on Motzei Shabbos for twenty years!

Variants§

§

BaChaG

§

BaShaH

§

GaChaH

§

HaKaZ

§

HaShA

§

ZaChA

§

ZaShaG

§

BaChaH

§

BaShaZ

§

GaKaZ

§

HaChA

§

HaShaG

§

ZaChaG

§

ZaShaH

Trait Implementations§

Source§

impl Clone for MonthSchedule

Source§

fn clone(&self) -> MonthSchedule

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 MonthSchedule

Source§

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

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

impl<'de> Deserialize<'de> for MonthSchedule

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for MonthSchedule

Source§

fn eq(&self, other: &MonthSchedule) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MonthSchedule

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for MonthSchedule

Source§

impl Eq for MonthSchedule

Source§

impl StructuralPartialEq for MonthSchedule

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,