pub enum Keviyah {
Show 14 variants בחג = 0, בשה = 1, גכה = 2, הכז = 3, השא = 4, זחא = 5, זשג = 6, בחה = 7, בשז = 8, גכז = 9, החא = 10, השג = 11, זחג = 12, זשה = 13,
}
Expand description

The Keviyah (קביעה) of a year. A year may be one of fourteen types, categorized by the day of week of the new year (the first number, 1 = Sunday), the type of year (Deficient, Regular, Complete), and the day of week of the first day of Passover. The last segment disambiguates between cases that have the same first two but differ on whether they are leap years (since Passover happens in Nisan, after the leap month Adar).

The discriminant values of these entries are according to the positions these keviyot appear in the Four Gates table, with the leap year ones being offset by 7. We don’t directly rely on this property but it is useful for potential bitpacking, and we use it as a way to double-check that the four gates code is set up correctly. We do directly rely on the leap-keviyot being after the regular ones (and starting with בחה) in is_leap.

For people unsure if their editor supports bidirectional text, the first Keviyah (2D3) is Bet (ב), Ḥet (ח), Gimel (ג).

(The Hebrew values are used in code for two reasons: firstly, Rust identifiers can’t start with a number, and secondly, sources differ on the Latin alphanumeric notation but use identical Hebrew notation)

Variants§

§

בחג = 0

2D3

§

בשה = 1

2C5

§

גכה = 2

3R5

§

הכז = 3

5R7

§

השא = 4

5C1

§

זחא = 5

7D1

§

זשג = 6

7C3

§

בחה = 7

2D5

§

בשז = 8

2C7

§

גכז = 9

3R7

§

החא = 10

5D1

§

השג = 11

5C3

§

זחג = 12

7D3

§

זשה = 13

7C5

Implementations§

source§

impl Keviyah

source

pub fn year_type(self) -> YearType

Get the type of year for this Keviyah.

Comes from the second letter in this Keviyah: ח = D, כ = R, ש = C

source

pub fn start_of_year(self) -> StartOfYear

Get the day of the new year for this Keviyah

Comes from the first letter in this Keviyah: ב = 2 = Monday, ג = 3 = Tuesday, ה = 5 = Thursday, ז = 7 = Saturday

source

fn normalized_ordinal_month(self, ordinal_month: u8) -> Option<u8>

Normalize the ordinal month to the “month number” in the year (ignoring leap months), i.e. Adar and Adar II are both represented by 6.

Returns None if given the index of Adar I (6 in a leap year)

source

pub fn month_len(self, ordinal_month: u8) -> u8

Given an ordinal, civil month (1-indexed month starting at Tishrei) return its length

source

pub fn days_preceding(self, ordinal_month: u8) -> u16

Get the number of days preceding this month

source

pub fn month_day_for(self, day: u16) -> (u8, u8)

Given a day of the year, return the ordinal month and day as (month, day).

source

pub fn last_month_day_in_year(self) -> (u8, u8)

Return the last ordinal month and day in this year as (month, day)

source

pub fn is_leap(self) -> bool

Whether this year is a leap year

source

pub fn year_info(self, h_year: i32) -> YearInfo

Given the hebrew year for this Keviyah, calculate the YearInfo

source

pub fn year_length(self) -> u16

How many days are in this year

source

pub fn from_integer(integer: u8) -> Self

Construct this from an integer between 0 and 13

Potentially useful for bitpacking

Trait Implementations§

source§

impl Clone for Keviyah

source§

fn clone(&self) -> Keviyah

Returns a copy 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 Keviyah

source§

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

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

impl Ord for Keviyah

source§

fn cmp(&self, other: &Keviyah) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Keviyah

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Keviyah

source§

fn partial_cmp(&self, other: &Keviyah) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Keviyah

source§

impl Eq for Keviyah

source§

impl StructuralPartialEq for Keviyah

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.