pub struct Chinese { /* private fields */ }Expand description
The Chinese Calendar
The Chinese Calendar is a lunisolar calendar used traditionally in China as well as in other countries particularly in, but not limited to, East Asia. It is often used today to track important cultural events and holidays like the Chinese Lunar New Year.
This type can be used with Date to represent dates in the Chinese calendar.
§Months
The Chinese calendar is an astronomical calendar which uses the phases of the moon to track months. Each month starts on the date of the new moon as observed from China, meaning that months last 29 or 30 days.
One year in the Chinese calendar is typically 12 lunar months; however, because 12 lunar months does not line up to one solar year, the Chinese calendar will add an intercalary leap month approximately every three years to keep Chinese calendar months in line with the solar year.
Leap months can happen after any month; the month in which a leap month occurs is based on the alignment of months with 24 solar terms into which the solar year is divided.
§Year and Era codes
Unlike the Gregorian calendar, the Chinese calendar does not traditionally count years in an infinitely increasing sequence. Instead, 10 “celestial stems” and 12 “terrestrial branches” are combined to form a cycle of year names which repeats every 60 years. However, for the purposes of calendar calculations and conversions, this calendar also counts years based on the ISO (Gregorian) calendar. This “related ISO year” marks the ISO year in which a Chinese year begins.
Because the Chinese calendar does not traditionally count years, era codes are not used in this calendar.
For more information, suggested reading materials include:
- Calendrical Calculations by Reingold & Dershowitz
 - The Mathematics of the Chinese Calendar by Helmer Aslaksen https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.139.9311&rep=rep1&type=pdf
 - Wikipedia: https://en.wikipedia.org/wiki/Chinese_calendar
 
§Month codes
This calendar is a lunisolar calendar. It supports regular month codes "M01" - "M12" as well
as leap month codes "M01L" - "M12L".
This calendar is currently in a preview state: formatting for this calendar is not going to be perfect.
Implementations§
Source§impl Chinese
 
impl Chinese
Sourcepub const fn new() -> Chinese
 
pub const fn new() -> Chinese
Creates a new Chinese with some precomputed calendrical calculations.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn try_new_with_buffer_provider(
    provider: &(impl BufferProvider + ?Sized),
) -> Result<Chinese, DataError>
 
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), ) -> Result<Chinese, DataError>
A version of [Self :: new] that uses custom data provided by a BufferProvider.
✨ Enabled with the serde feature.
Sourcepub fn try_new_unstable<D>(provider: &D) -> Result<Chinese, DataError>
 
pub fn try_new_unstable<D>(provider: &D) -> Result<Chinese, DataError>
A version of Self::new that uses custom data provided by a DataProvider.
Sourcepub fn new_always_calculating() -> Chinese
 
pub fn new_always_calculating() -> Chinese
Construct a new Chinese without any precomputed calendrical calculations.
Trait Implementations§
Source§impl Calendar for Chinese
 
impl Calendar for Chinese
Source§fn debug_name(&self) -> &'static str
 
fn debug_name(&self) -> &'static str
Obtain a name for the calendar for debug printing
Source§fn month(&self, date: &<Chinese as Calendar>::DateInner) -> MonthInfo
 
fn month(&self, date: &<Chinese as Calendar>::DateInner) -> MonthInfo
The calendar-specific month code represented by date;
since the Chinese calendar has leap months, an “L” is appended to the month code for
leap months. For example, in a year where an intercalary month is added after the second
month, the month codes for ordinal months 1, 2, 3, 4, 5 would be “M01”, “M02”, “M02L”, “M03”, “M04”.
Source§fn day_of_month(&self, date: &<Chinese as Calendar>::DateInner) -> DayOfMonth
 
fn day_of_month(&self, date: &<Chinese as Calendar>::DateInner) -> DayOfMonth
The calendar-specific day-of-month represented by date
Source§fn day_of_year(&self, date: &<Chinese as Calendar>::DateInner) -> DayOfYear
 
fn day_of_year(&self, date: &<Chinese as Calendar>::DateInner) -> DayOfYear
Information of the day of the year
Source§type Year = CyclicYear
 
type Year = CyclicYear
Source§fn from_codes(
    &self,
    era: Option<&str>,
    year: i32,
    month_code: MonthCode,
    day: u8,
) -> Result<<Chinese as Calendar>::DateInner, DateError>
 
fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<<Chinese as Calendar>::DateInner, DateError>
Source§fn from_rata_die(&self, rd: RataDie) -> <Chinese as Calendar>::DateInner
 
fn from_rata_die(&self, rd: RataDie) -> <Chinese as Calendar>::DateInner
RataDieSource§fn to_rata_die(&self, date: &<Chinese as Calendar>::DateInner) -> RataDie
 
fn to_rata_die(&self, date: &<Chinese as Calendar>::DateInner) -> RataDie
RataDie from this dateSource§fn from_iso(&self, iso: IsoDateInner) -> <Chinese as Calendar>::DateInner
 
fn from_iso(&self, iso: IsoDateInner) -> <Chinese as Calendar>::DateInner
Source§fn to_iso(&self, date: &<Chinese as Calendar>::DateInner) -> IsoDateInner
 
fn to_iso(&self, date: &<Chinese as Calendar>::DateInner) -> IsoDateInner
Source§fn days_in_year(&self, date: &<Chinese as Calendar>::DateInner) -> u16
 
fn days_in_year(&self, date: &<Chinese as Calendar>::DateInner) -> u16
Source§fn days_in_month(&self, date: &<Chinese as Calendar>::DateInner) -> u8
 
fn days_in_month(&self, date: &<Chinese as Calendar>::DateInner) -> u8
Source§fn year_info(
    &self,
    date: &<Chinese as Calendar>::DateInner,
) -> <Chinese as Calendar>::Year
 
fn year_info( &self, date: &<Chinese as Calendar>::DateInner, ) -> <Chinese as Calendar>::Year
Source§fn extended_year(&self, date: &<Chinese as Calendar>::DateInner) -> i32
 
fn extended_year(&self, date: &<Chinese as Calendar>::DateInner) -> i32
Source§fn is_in_leap_year(&self, date: &<Chinese as Calendar>::DateInner) -> bool
 
fn is_in_leap_year(&self, date: &<Chinese as Calendar>::DateInner) -> bool
Source§fn calendar_algorithm(&self) -> Option<CalendarAlgorithm>
 
fn calendar_algorithm(&self) -> Option<CalendarAlgorithm>
CalendarAlgorithm that is required to match
when parsing into this calendar. Read moreSource§impl CldrCalendar for Chinese
 
impl CldrCalendar for Chinese
Source§type YearNamesV1 = DatetimeNamesYearChineseV1
 
type YearNamesV1 = DatetimeNamesYearChineseV1
Source§type MonthNamesV1 = DatetimeNamesMonthChineseV1
 
type MonthNamesV1 = DatetimeNamesMonthChineseV1
Source§type SkeletaV1 = DatetimePatternsDateChineseV1
 
type SkeletaV1 = DatetimePatternsDateChineseV1
Source§impl From<Chinese> for AnyCalendar
 
impl From<Chinese> for AnyCalendar
Source§fn from(value: Chinese) -> AnyCalendar
 
fn from(value: Chinese) -> AnyCalendar
Source§impl IntoAnyCalendar for Chinese
 
impl IntoAnyCalendar for Chinese
Source§fn to_any(self) -> AnyCalendar
 
fn to_any(self) -> AnyCalendar
AnyCalendar, moving it Read moreSource§fn kind(&self) -> AnyCalendarKind
 
fn kind(&self) -> AnyCalendarKind
AnyCalendarKind enum variant associated with this calendarSource§fn from_any(any: AnyCalendar) -> Result<Chinese, AnyCalendar>
 
fn from_any(any: AnyCalendar) -> Result<Chinese, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Chinese>
 
fn from_any_ref(any: &AnyCalendar) -> Option<&Chinese>
Source§impl Ord for Chinese
 
impl Ord for Chinese
Source§impl PartialOrd for Chinese
 
impl PartialOrd for Chinese
impl Eq for Chinese
impl IntoFormattableAnyCalendar for Chinese
impl UnstableSealed for Chinese
impl UnstableSealed for Chinese
Auto Trait Implementations§
impl Freeze for Chinese
impl RefUnwindSafe for Chinese
impl !Send for Chinese
impl !Sync for Chinese
impl Unpin for Chinese
impl UnwindSafe for Chinese
Blanket Implementations§
Source§impl<C> AsCalendar for Cwhere
    C: Calendar,
 
impl<C> AsCalendar for Cwhere
    C: Calendar,
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more