pub struct EastAsianTraditional<R>(pub R);Expand description
The traditional East-Asian lunisolar calendar.
This calendar used traditionally in China as well as in other countries in East Asia is often used today to track important cultural events and holidays like the Lunar New Year.
The type parameter specifies a particular set of calculation rules and local
time information, which differs by country and over time.
It must implement the currently-unstable Rules trait, at the moment this crate exports two stable
implementors of Rules: China and Korea. Please comment on this issue
if you would like to see this trait stabilized.
This corresponds to the "chinese" and "dangi" CLDR calendars
respectively, when used with the China and Korea [Rules] types.
§Year and Era codes
Unlike most calendars, the traditional East-Asian 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 Gregorian (ISO) calendar.
This “related ISO year” marks the Gregorian year in which a traditional East-Asian year begins.
Because the traditional East-Asian 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
§Months and days
The 12 months (M01-M12) don’t use names in modern usage, instead they are referred to as
e.g. 三月 (third month) using Chinese characters.
As a lunar calendar, the lengths of the months depend on the lunar cycle (a month starts on the day of
local new moon), and will be either 29 or 30 days. As 12 such months fall short of a solar year, a leap
month is inserted roughly every 3 years; this can be after any month (e.g. M02L).
Both the lengths of the months and the occurence of leap months are determined by the
concrete [Rules] implementation.
The length of the year is 353-355 days, and the length of the leap year 383-385 days.
§Calendar drift
As leap months are determined with respect to the solar year, this calendar stays anchored to the seasons.
Tuple Fields§
§0: RImplementations§
Source§impl EastAsianTraditional<Korea>
impl EastAsianTraditional<Korea>
Sourcepub const fn new() -> EastAsianTraditional<Korea>
pub const fn new() -> EastAsianTraditional<Korea>
Creates a new KoreanTraditional calendar.
Sourcepub fn try_new_with_buffer_provider(
_provider: &(impl BufferProvider + ?Sized),
) -> Result<EastAsianTraditional<Korea>, DataError>
👎Deprecated since 2.1.0: use `Self::new()
pub fn try_new_with_buffer_provider( _provider: &(impl BufferProvider + ?Sized), ) -> Result<EastAsianTraditional<Korea>, DataError>
Use Self::new.
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<EastAsianTraditional<Korea>, DataError>where
D: ?Sized,
👎Deprecated since 2.1.0: use `Self::new()
pub fn try_new_unstable<D>(
_provider: &D,
) -> Result<EastAsianTraditional<Korea>, DataError>where
D: ?Sized,
Use Self::new.
A version of Self::new that uses custom data provided by a DataProvider.
Sourcepub fn new_always_calculating() -> EastAsianTraditional<Korea>
👎Deprecated since 2.1.0: use `Self::new()
pub fn new_always_calculating() -> EastAsianTraditional<Korea>
Use Self::new.
Source§impl EastAsianTraditional<China>
impl EastAsianTraditional<China>
Sourcepub const fn new() -> EastAsianTraditional<China>
pub const fn new() -> EastAsianTraditional<China>
Creates a new ChineseTraditional calendar.
Sourcepub fn try_new_with_buffer_provider(
_provider: &(impl BufferProvider + ?Sized),
) -> Result<EastAsianTraditional<China>, DataError>
👎Deprecated since 2.1.0: use `Self::new()
pub fn try_new_with_buffer_provider( _provider: &(impl BufferProvider + ?Sized), ) -> Result<EastAsianTraditional<China>, 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<EastAsianTraditional<China>, DataError>where
D: ?Sized,
👎Deprecated since 2.1.0: use `Self::new()
pub fn try_new_unstable<D>(
_provider: &D,
) -> Result<EastAsianTraditional<China>, DataError>where
D: ?Sized,
A version of Self::new that uses custom data provided by a DataProvider.
Sourcepub fn new_always_calculating() -> EastAsianTraditional<China>
👎Deprecated since 2.1.0: use `Self::new()
pub fn new_always_calculating() -> EastAsianTraditional<China>
Use Self::new().
Trait Implementations§
Source§impl<R> Calendar for EastAsianTraditional<R>where
R: Rules,
impl<R> Calendar for EastAsianTraditional<R>where
R: Rules,
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: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> MonthInfo
fn month( &self, date: &<EastAsianTraditional<R> 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: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> DayOfMonth
fn day_of_month( &self, date: &<EastAsianTraditional<R> as Calendar>::DateInner, ) -> DayOfMonth
The calendar-specific day-of-month represented by date
Source§fn day_of_year(
&self,
date: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> DayOfYear
fn day_of_year( &self, date: &<EastAsianTraditional<R> as Calendar>::DateInner, ) -> DayOfYear
Information of the day of the year
Source§type Year = CyclicYear
type Year = CyclicYear
Source§type DifferenceError = Infallible
type DifferenceError = Infallible
untilSource§fn from_codes(
&self,
era: Option<&str>,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<<EastAsianTraditional<R> as Calendar>::DateInner, DateError>
fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<<EastAsianTraditional<R> as Calendar>::DateInner, DateError>
Source§fn from_rata_die(
&self,
rd: RataDie,
) -> <EastAsianTraditional<R> as Calendar>::DateInner
fn from_rata_die( &self, rd: RataDie, ) -> <EastAsianTraditional<R> as Calendar>::DateInner
RataDieSource§fn to_rata_die(
&self,
date: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> RataDie
fn to_rata_die( &self, date: &<EastAsianTraditional<R> as Calendar>::DateInner, ) -> RataDie
RataDie from this dateSource§fn has_cheap_iso_conversion(&self) -> bool
fn has_cheap_iso_conversion(&self) -> bool
from_iso/to_iso is more efficient
than from_rata_die/to_rata_die.Source§fn days_in_year(
&self,
date: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> u16
fn days_in_year( &self, date: &<EastAsianTraditional<R> as Calendar>::DateInner, ) -> u16
Source§fn days_in_month(
&self,
date: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> u8
fn days_in_month( &self, date: &<EastAsianTraditional<R> as Calendar>::DateInner, ) -> u8
Source§fn year_info(
&self,
date: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> <EastAsianTraditional<R> as Calendar>::Year
fn year_info( &self, date: &<EastAsianTraditional<R> as Calendar>::DateInner, ) -> <EastAsianTraditional<R> as Calendar>::Year
Source§fn is_in_leap_year(
&self,
date: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> bool
fn is_in_leap_year( &self, date: &<EastAsianTraditional<R> 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§fn months_in_year(
&self,
date: &<EastAsianTraditional<R> as Calendar>::DateInner,
) -> u8
fn months_in_year( &self, date: &<EastAsianTraditional<R> as Calendar>::DateInner, ) -> u8
Source§fn from_iso(&self, iso: IsoDateInner) -> Self::DateInner
fn from_iso(&self, iso: IsoDateInner) -> Self::DateInner
Source§fn to_iso(&self, date: &Self::DateInner) -> IsoDateInner
fn to_iso(&self, date: &Self::DateInner) -> IsoDateInner
Source§fn extended_year(&self, date: &Self::DateInner) -> i32
fn extended_year(&self, date: &Self::DateInner) -> i32
Source§impl CldrCalendar for EastAsianTraditional<China>
impl CldrCalendar for EastAsianTraditional<China>
Source§type YearNamesV1 = DatetimeNamesYearChineseV1
type YearNamesV1 = DatetimeNamesYearChineseV1
Source§type MonthNamesV1 = DatetimeNamesMonthChineseV1
type MonthNamesV1 = DatetimeNamesMonthChineseV1
Source§type SkeletaV1 = DatetimePatternsDateChineseV1
type SkeletaV1 = DatetimePatternsDateChineseV1
Source§impl CldrCalendar for EastAsianTraditional<Korea>
impl CldrCalendar for EastAsianTraditional<Korea>
Source§type YearNamesV1 = DatetimeNamesYearDangiV1
type YearNamesV1 = DatetimeNamesYearDangiV1
Source§type MonthNamesV1 = DatetimeNamesMonthDangiV1
type MonthNamesV1 = DatetimeNamesMonthDangiV1
Source§type SkeletaV1 = DatetimePatternsDateDangiV1
type SkeletaV1 = DatetimePatternsDateDangiV1
Source§impl<R> Clone for EastAsianTraditional<R>where
R: Clone,
impl<R> Clone for EastAsianTraditional<R>where
R: Clone,
Source§fn clone(&self) -> EastAsianTraditional<R>
fn clone(&self) -> EastAsianTraditional<R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<R> Debug for EastAsianTraditional<R>where
R: Debug,
impl<R> Debug for EastAsianTraditional<R>where
R: Debug,
Source§impl<R> Default for EastAsianTraditional<R>where
R: Default,
impl<R> Default for EastAsianTraditional<R>where
R: Default,
Source§fn default() -> EastAsianTraditional<R>
fn default() -> EastAsianTraditional<R>
Source§impl From<EastAsianTraditional<China>> for AnyCalendar
impl From<EastAsianTraditional<China>> for AnyCalendar
Source§fn from(value: EastAsianTraditional<China>) -> AnyCalendar
fn from(value: EastAsianTraditional<China>) -> AnyCalendar
Source§impl From<EastAsianTraditional<Korea>> for AnyCalendar
impl From<EastAsianTraditional<Korea>> for AnyCalendar
Source§fn from(value: EastAsianTraditional<Korea>) -> AnyCalendar
fn from(value: EastAsianTraditional<Korea>) -> AnyCalendar
Source§impl IntoAnyCalendar for EastAsianTraditional<China>
impl IntoAnyCalendar for EastAsianTraditional<China>
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<EastAsianTraditional<China>, AnyCalendar>
fn from_any( any: AnyCalendar, ) -> Result<EastAsianTraditional<China>, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&EastAsianTraditional<China>>
fn from_any_ref(any: &AnyCalendar) -> Option<&EastAsianTraditional<China>>
Source§fn date_to_any(
&self,
d: &<EastAsianTraditional<China> as Calendar>::DateInner,
) -> AnyDateInner
fn date_to_any( &self, d: &<EastAsianTraditional<China> as Calendar>::DateInner, ) -> AnyDateInner
AnyDateInner Read moreSource§impl IntoAnyCalendar for EastAsianTraditional<Korea>
impl IntoAnyCalendar for EastAsianTraditional<Korea>
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<EastAsianTraditional<Korea>, AnyCalendar>
fn from_any( any: AnyCalendar, ) -> Result<EastAsianTraditional<Korea>, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&EastAsianTraditional<Korea>>
fn from_any_ref(any: &AnyCalendar) -> Option<&EastAsianTraditional<Korea>>
Source§fn date_to_any(
&self,
d: &<EastAsianTraditional<Korea> as Calendar>::DateInner,
) -> AnyDateInner
fn date_to_any( &self, d: &<EastAsianTraditional<Korea> as Calendar>::DateInner, ) -> AnyDateInner
AnyDateInner Read moreSource§impl<R> Ord for EastAsianTraditional<R>where
R: Ord,
impl<R> Ord for EastAsianTraditional<R>where
R: Ord,
Source§fn cmp(&self, other: &EastAsianTraditional<R>) -> Ordering
fn cmp(&self, other: &EastAsianTraditional<R>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<R> PartialEq for EastAsianTraditional<R>where
R: PartialEq,
impl<R> PartialEq for EastAsianTraditional<R>where
R: PartialEq,
Source§impl<R> PartialOrd for EastAsianTraditional<R>where
R: PartialOrd,
impl<R> PartialOrd for EastAsianTraditional<R>where
R: PartialOrd,
impl<R> Copy for EastAsianTraditional<R>where
R: Copy,
impl<R> Eq for EastAsianTraditional<R>where
R: Eq,
impl IntoFormattableAnyCalendar for EastAsianTraditional<China>
impl IntoFormattableAnyCalendar for EastAsianTraditional<Korea>
impl<R> StructuralPartialEq for EastAsianTraditional<R>
impl UnstableSealed for EastAsianTraditional<China>
impl UnstableSealed for EastAsianTraditional<Korea>
Auto Trait Implementations§
impl<R> Freeze for EastAsianTraditional<R>where
R: Freeze,
impl<R> RefUnwindSafe for EastAsianTraditional<R>where
R: RefUnwindSafe,
impl<R> Send for EastAsianTraditional<R>where
R: Send,
impl<R> Sync for EastAsianTraditional<R>where
R: Sync,
impl<R> Unpin for EastAsianTraditional<R>where
R: Unpin,
impl<R> UnwindSafe for EastAsianTraditional<R>where
R: UnwindSafe,
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> GetField<T> for Twhere
T: Copy + UnstableSealed,
impl<T> GetField<T> for Twhere
T: Copy + UnstableSealed,
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