#[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
Source§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 PartialOrd for PackedChineseBasedYearInfo
impl PartialOrd for PackedChineseBasedYearInfo
Source§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