pub struct Gregorian;Expand description
The Gregorian calendar is an improvement over the Julian calendar.
It was adopted under Pope Gregory XIII in 1582 CE by much of Roman Catholic Europe,
and over the following centuries by all other countries that had been using
the Julian calendar. Eventually even countries that had been using other calendars
adopted this calendar, and today it is used as the international civil calendar.
This implementation extends proleptically for dates before the calendar’s creation.
This corresponds to the "gregory" CLDR calendar.
§Era codes
This calendar uses two era codes: bce (alias bc), and ce (alias ad), corresponding to the BCE and CE eras.
§Months and days
The 12 months are called January (M01, 31 days), February (M02, 28 days),
March (M03, 31 days), April (M04, 30 days), May (M05, 31 days), June (M06, 30 days),
July (M07, 31 days), August (M08, 31 days), September (M09, 30 days),
October (M10, 31 days), November (M11, 30 days), December (M12, 31 days).
In leap years (years divisible by 4 but not 100 except when divisble by 400), February gains a 29th day.
Standard years thus have 365 days, and leap years 366.
§Calendar drift
The Gregorian calendar has an average year length of 365.2425, slightly longer than the mean solar year, so this calendar drifts 1 day in ~7700 years with respect to the seasons.
§Historical accuracy
This type implements the proleptic Gregorian calendar, with dates before 1582 CE using the rules projected backwards. Care needs to be taken when intepreting historical dates before or during the transition from the Julian to the Gregorian calendar. Some regions continued using the Julian calendar as late as the 20th century. Sources often mark dates as “New Style” (Gregorian) or “Old Style” (Julian) if there is ambiguity.
Historically, the Julian/Gregorian calendars were used with a variety of year reckoning
schemes (see Julian for more detail). The Gregorian calendar has generally
been used with the Anno Domini/Common era since its inception. However, some countries
that have adopted the Gregorian calendar more recently are still using their traditional
year-reckoning schemes. This crate implements some of these as different types, i.e the Thai
Buddhist calendar, the Japanese calendar, and the
Chinese Republican Calendar (Roc).
Implementations§
Trait Implementations§
Source§impl Calendar for Gregorian
impl Calendar for Gregorian
Source§type DifferenceError = Infallible
type DifferenceError = Infallible
untilSource§fn from_codes(
&self,
era: Option<&str>,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<<Gregorian as Calendar>::DateInner, DateError>
fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<<Gregorian as Calendar>::DateInner, DateError>
Source§fn from_rata_die(&self, rd: RataDie) -> <Gregorian as Calendar>::DateInner
fn from_rata_die(&self, rd: RataDie) -> <Gregorian as Calendar>::DateInner
RataDieSource§fn to_rata_die(&self, date: &<Gregorian as Calendar>::DateInner) -> RataDie
fn to_rata_die(&self, date: &<Gregorian 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 from_iso(&self, iso: IsoDateInner) -> <Gregorian as Calendar>::DateInner
fn from_iso(&self, iso: IsoDateInner) -> <Gregorian as Calendar>::DateInner
Source§fn to_iso(&self, date: &<Gregorian as Calendar>::DateInner) -> IsoDateInner
fn to_iso(&self, date: &<Gregorian as Calendar>::DateInner) -> IsoDateInner
Source§fn months_in_year(&self, date: &<Gregorian as Calendar>::DateInner) -> u8
fn months_in_year(&self, date: &<Gregorian as Calendar>::DateInner) -> u8
Source§fn days_in_year(&self, date: &<Gregorian as Calendar>::DateInner) -> u16
fn days_in_year(&self, date: &<Gregorian as Calendar>::DateInner) -> u16
Source§fn days_in_month(&self, date: &<Gregorian as Calendar>::DateInner) -> u8
fn days_in_month(&self, date: &<Gregorian as Calendar>::DateInner) -> u8
Source§fn year_info(
&self,
date: &<Gregorian as Calendar>::DateInner,
) -> <Gregorian as Calendar>::Year
fn year_info( &self, date: &<Gregorian as Calendar>::DateInner, ) -> <Gregorian as Calendar>::Year
Source§fn is_in_leap_year(&self, date: &<Gregorian as Calendar>::DateInner) -> bool
fn is_in_leap_year(&self, date: &<Gregorian as Calendar>::DateInner) -> bool
Source§fn month(&self, date: &<Gregorian as Calendar>::DateInner) -> MonthInfo
fn month(&self, date: &<Gregorian as Calendar>::DateInner) -> MonthInfo
dateSource§fn day_of_month(&self, date: &<Gregorian as Calendar>::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &<Gregorian as Calendar>::DateInner) -> DayOfMonth
dateSource§fn day_of_year(&self, date: &<Gregorian as Calendar>::DateInner) -> DayOfYear
fn day_of_year(&self, date: &<Gregorian as Calendar>::DateInner) -> DayOfYear
Source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
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 extended_year(&self, date: &Self::DateInner) -> i32
fn extended_year(&self, date: &Self::DateInner) -> i32
Source§impl CldrCalendar for Gregorian
impl CldrCalendar for Gregorian
Source§type YearNamesV1 = DatetimeNamesYearGregorianV1
type YearNamesV1 = DatetimeNamesYearGregorianV1
Source§type MonthNamesV1 = DatetimeNamesMonthGregorianV1
type MonthNamesV1 = DatetimeNamesMonthGregorianV1
Source§type SkeletaV1 = DatetimePatternsDateGregorianV1
type SkeletaV1 = DatetimePatternsDateGregorianV1
Source§impl From<Gregorian> for AnyCalendar
impl From<Gregorian> for AnyCalendar
Source§fn from(value: Gregorian) -> AnyCalendar
fn from(value: Gregorian) -> AnyCalendar
Source§impl IntoAnyCalendar for Gregorian
impl IntoAnyCalendar for Gregorian
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<Gregorian, AnyCalendar>
fn from_any(any: AnyCalendar) -> Result<Gregorian, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Gregorian>
fn from_any_ref(any: &AnyCalendar) -> Option<&Gregorian>
impl Copy for Gregorian
impl IntoFormattableAnyCalendar for Gregorian
impl UnstableSealed for Gregorian
Auto Trait Implementations§
impl Freeze for Gregorian
impl RefUnwindSafe for Gregorian
impl Send for Gregorian
impl Sync for Gregorian
impl Unpin for Gregorian
impl UnwindSafe for Gregorian
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