#[repr(C, packed(1))]pub struct PackedChineseBasedYearInfo(pub u8, pub u8, pub u8);
Expand description
The struct containing compiled ChineseData
Bit structure (little endian: note that shifts go in the opposite direction!)
Bit: 0 1 2 3 4 5 6 7
Byte 0: [ month lengths .............
Byte 1: .. month lengths ] | [ leap month index ..
Byte 2: ] | [ NY offset ] | unused
Where the New Year Offset is the offset from ISO Jan 21 of that year for Chinese New Year, the month lengths are stored as 1 = 30, 0 = 29 for each month including the leap month. The largest possible offset is 33, which requires 6 bits of storage.
Tuple Fieldsยง
ยง0: u8
ยง1: u8
ยง2: u8
Implementationsยง
sourceยงimpl PackedChineseBasedYearInfo
impl PackedChineseBasedYearInfo
sourcepub(crate) const FIRST_NY: u8 = 19u8
pub(crate) const FIRST_NY: u8 = 19u8
The first day of the ISO year on which Chinese New Year may occur
According to Reingold & Dershowitz, ch 19.6, Chinese New Year occurs on Jan 21 - Feb 21 inclusive.
Chinese New Year in the year 30 AD is January 20 (30-01-20).
We allow it to occur as early as January 19 which is the earliest the second new moon could occur after the Winter Solstice if the solstice is pinned to December 20.
pub(crate) fn new( month_lengths: [bool; 13], leap_month_idx: Option<NonZeroU8>, ny_offset: u8, ) -> Self
pub(crate) fn ny_offset(self) -> u8
sourcefn ny_day_of_iso_year(self) -> u8
fn ny_day_of_iso_year(self) -> u8
The day of the year (1-indexed) that this is in the ISO year
pub(crate) fn ny_rd(self, related_iso: i32) -> RataDie
pub(crate) fn leap_month_idx(self) -> Option<NonZeroU8>
pub(crate) fn last_day_of_month(self, month: u8) -> u16
pub(crate) fn days_in_year(self) -> u16
Trait Implementationsยง
sourceยงimpl AsULE for PackedChineseBasedYearInfo
impl AsULE for PackedChineseBasedYearInfo
ยงtype ULE = PackedChineseBasedYearInfo
type ULE = PackedChineseBasedYearInfo
Self
. Read moresourceยงfn to_unaligned(self) -> Self
fn to_unaligned(self) -> Self
sourceยงfn from_unaligned(other: Self) -> Self
fn from_unaligned(other: Self) -> Self
sourceยงimpl Clone for PackedChineseBasedYearInfo
impl Clone for PackedChineseBasedYearInfo
sourceยงfn clone(&self) -> PackedChineseBasedYearInfo
fn clone(&self) -> PackedChineseBasedYearInfo
1.0.0 ยท sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceยงimpl Debug for PackedChineseBasedYearInfo
impl Debug for PackedChineseBasedYearInfo
sourceยงimpl Ord for PackedChineseBasedYearInfo
impl Ord for PackedChineseBasedYearInfo
sourceยงfn cmp(&self, other: &PackedChineseBasedYearInfo) -> Ordering
fn cmp(&self, other: &PackedChineseBasedYearInfo) -> Ordering
1.21.0 ยท sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
sourceยงimpl PartialEq for PackedChineseBasedYearInfo
impl PartialEq for PackedChineseBasedYearInfo
sourceยงfn eq(&self, other: &PackedChineseBasedYearInfo) -> bool
fn eq(&self, other: &PackedChineseBasedYearInfo) -> bool
self
and other
values to be equal, and is used
by ==
.sourceยงimpl PartialOrd for PackedChineseBasedYearInfo
impl PartialOrd for PackedChineseBasedYearInfo
sourceยงfn partial_cmp(&self, other: &PackedChineseBasedYearInfo) -> Option<Ordering>
fn partial_cmp(&self, other: &PackedChineseBasedYearInfo) -> Option<Ordering>
1.0.0 ยท sourceยงfn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceยงimpl ULE for PackedChineseBasedYearInfo
impl ULE for PackedChineseBasedYearInfo
sourceยงfn validate_byte_slice(bytes: &[u8]) -> Result<(), ZeroVecError>
fn validate_byte_slice(bytes: &[u8]) -> Result<(), ZeroVecError>
&[u8]
. Read moresourceยงfn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], ZeroVecError>
fn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], ZeroVecError>
sourceยงunsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &[Self]
unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &[Self]
&[u8]
, and return it as &[Self]
with the same lifetime, assuming
that this byte slice has previously been run through Self::parse_byte_slice()
with
success. Read more