pub struct Hijri<S>(pub S);Expand description
The Hijri Calendar
There are many variants of this calendar, using different lunar observations or calculations
(see [Rules]). Currently, [Rules] is an unstable trait, but some of its implementors
are stable, and can be constructed via the various Hijri::new_* constructors. Please comment
on this issue
if you would like to see this the ability to implement custom [Rules] stabilized.
This implementation supports only variants where months are either 29 or 30 days.
This corresponds to various "islamic-*" CLDR calendars,
see the individual implementors of [Rules] (TabularAlgorithm, UmmAlQura, AstronomicalSimulation) for more information.
§Era codes
This calendar uses two era codes: ah, and bh, corresponding to the Anno Hegirae and Before Hijrah eras
§Months and days
The 12 months are called al-Muḥarram (M01), Ṣafar (M02), Rabīʿ al-ʾAwwal (M03),
Rabīʿ ath-Thānī or Rabīʿ al-ʾĀkhir (M04), Jumādā al-ʾŪlā (M05), Jumādā ath-Thāniyah
or Jumādā al-ʾĀkhirah (M06), Rajab (M07), Shaʿbān (M08), Ramaḍān (M09), Shawwāl (M10),
Ḏū al-Qaʿdah (M11), Ḏū al-Ḥijjah (M12).
As a true lunar calendar, the lengths of the months depend on the lunar cycle (a month starts on the day where the waxing crescent is first observed), and will be either 29 or 30 days.
The lengths of the months are determined by the concrete [Rules] implementation.
There are either 6 or 7 30-day months, so the length of the year is 354 or 355 days.
§Calendar drift
As a lunar calendar, this calendar does not intend to follow the solar year, and drifts more than 10 days per year with respect to the seasons.
Tuple Fields§
§0: SImplementations§
Source§impl Hijri<AstronomicalSimulation>
impl Hijri<AstronomicalSimulation>
Sourcepub const fn new_mecca() -> Hijri<AstronomicalSimulation>
👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
pub const fn new_mecca() -> Hijri<AstronomicalSimulation>
Hijri::new_simulated_meccaSourcepub const fn new_simulated_mecca() -> Hijri<AstronomicalSimulation>
pub const fn new_simulated_mecca() -> Hijri<AstronomicalSimulation>
Creates a Hijri calendar using simulated sightings at Mecca.
These simulations are unofficial and are known to not necessarily match sightings
on the ground. Unless you know otherwise for sure, instead of this variant, use
Hijri::new_umm_al_qura, which uses the results of KACST’s Mecca-based calculations.
Sourcepub fn try_new_mecca_with_buffer_provider(
_provider: &(impl BufferProvider + ?Sized),
) -> Result<Hijri<AstronomicalSimulation>, DataError>
👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
pub fn try_new_mecca_with_buffer_provider( _provider: &(impl BufferProvider + ?Sized), ) -> Result<Hijri<AstronomicalSimulation>, DataError>
Hijri::new_simulated_meccaA version of Self::new that uses custom data provided by a BufferProvider.
✨ Enabled with the serde feature.
Sourcepub fn try_new_mecca_unstable<D>(
_provider: &D,
) -> Result<Hijri<AstronomicalSimulation>, DataError>where
D: ?Sized,
👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
pub fn try_new_mecca_unstable<D>(
_provider: &D,
) -> Result<Hijri<AstronomicalSimulation>, DataError>where
D: ?Sized,
Hijri::new_simulated_meccaA version of Self::new_mecca that uses custom data provided by a DataProvider.
Sourcepub const fn new_mecca_always_calculating() -> Hijri<AstronomicalSimulation>
👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
pub const fn new_mecca_always_calculating() -> Hijri<AstronomicalSimulation>
Hijri::new_simulated_meccaSource§impl Hijri<TabularAlgorithm>
impl Hijri<TabularAlgorithm>
Sourcepub const fn new(
leap_years: TabularAlgorithmLeapYears,
epoch: TabularAlgorithmEpoch,
) -> Hijri<TabularAlgorithm>
👎Deprecated since 2.1.0: use Hijri::new_tabular
pub const fn new( leap_years: TabularAlgorithmLeapYears, epoch: TabularAlgorithmEpoch, ) -> Hijri<TabularAlgorithm>
Hijri::new_tabularSourcepub const fn new_tabular(
leap_years: TabularAlgorithmLeapYears,
epoch: TabularAlgorithmEpoch,
) -> Hijri<TabularAlgorithm>
pub const fn new_tabular( leap_years: TabularAlgorithmLeapYears, epoch: TabularAlgorithmEpoch, ) -> Hijri<TabularAlgorithm>
Creates a Hijri calendar with tabular rules and the given leap year rule and epoch.
Trait Implementations§
Source§impl<R> Calendar for Hijri<R>where
R: Rules,
impl<R> Calendar for Hijri<R>where
R: Rules,
Source§type DifferenceError = Infallible
type DifferenceError = Infallible
untilSource§fn from_codes(
&self,
era: Option<&str>,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<<Hijri<R> as Calendar>::DateInner, DateError>
fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<<Hijri<R> as Calendar>::DateInner, DateError>
Source§fn from_rata_die(&self, rd: RataDie) -> <Hijri<R> as Calendar>::DateInner
fn from_rata_die(&self, rd: RataDie) -> <Hijri<R> as Calendar>::DateInner
RataDieSource§fn to_rata_die(&self, date: &<Hijri<R> as Calendar>::DateInner) -> RataDie
fn to_rata_die(&self, date: &<Hijri<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 months_in_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u8
fn months_in_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u8
Source§fn days_in_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u16
fn days_in_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u16
Source§fn days_in_month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u8
fn days_in_month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u8
Source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
Source§fn year_info(
&self,
date: &<Hijri<R> as Calendar>::DateInner,
) -> <Hijri<R> as Calendar>::Year
fn year_info( &self, date: &<Hijri<R> as Calendar>::DateInner, ) -> <Hijri<R> as Calendar>::Year
Source§fn is_in_leap_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> bool
fn is_in_leap_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> bool
Source§fn month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> MonthInfo
fn month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> MonthInfo
dateSource§fn day_of_month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> DayOfMonth
dateSource§fn day_of_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> DayOfYear
fn day_of_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> DayOfYear
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 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<R> CldrCalendar for Hijri<R>where
R: FormattableHijriRules,
impl<R> CldrCalendar for Hijri<R>where
R: FormattableHijriRules,
Source§type YearNamesV1 = <R as FormattableHijriRules>::YearNamesV1
type YearNamesV1 = <R as FormattableHijriRules>::YearNamesV1
Source§type MonthNamesV1 = <R as FormattableHijriRules>::MonthNamesV1
type MonthNamesV1 = <R as FormattableHijriRules>::MonthNamesV1
Source§type SkeletaV1 = <R as FormattableHijriRules>::SkeletaV1
type SkeletaV1 = <R as FormattableHijriRules>::SkeletaV1
Source§impl From<Hijri<AstronomicalSimulation>> for AnyCalendar
impl From<Hijri<AstronomicalSimulation>> for AnyCalendar
Source§fn from(value: Hijri<AstronomicalSimulation>) -> AnyCalendar
fn from(value: Hijri<AstronomicalSimulation>) -> AnyCalendar
Source§impl From<Hijri<TabularAlgorithm>> for AnyCalendar
impl From<Hijri<TabularAlgorithm>> for AnyCalendar
Source§fn from(value: Hijri<TabularAlgorithm>) -> AnyCalendar
fn from(value: Hijri<TabularAlgorithm>) -> AnyCalendar
Source§impl IntoAnyCalendar for Hijri<AstronomicalSimulation>
impl IntoAnyCalendar for Hijri<AstronomicalSimulation>
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<Hijri<AstronomicalSimulation>, AnyCalendar>
fn from_any( any: AnyCalendar, ) -> Result<Hijri<AstronomicalSimulation>, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<AstronomicalSimulation>>
fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<AstronomicalSimulation>>
Source§fn date_to_any(
&self,
d: &<Hijri<AstronomicalSimulation> as Calendar>::DateInner,
) -> AnyDateInner
fn date_to_any( &self, d: &<Hijri<AstronomicalSimulation> as Calendar>::DateInner, ) -> AnyDateInner
AnyDateInner Read moreSource§impl IntoAnyCalendar for Hijri<TabularAlgorithm>
impl IntoAnyCalendar for Hijri<TabularAlgorithm>
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<Hijri<TabularAlgorithm>, AnyCalendar>
fn from_any(any: AnyCalendar) -> Result<Hijri<TabularAlgorithm>, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<TabularAlgorithm>>
fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<TabularAlgorithm>>
Source§fn date_to_any(
&self,
d: &<Hijri<TabularAlgorithm> as Calendar>::DateInner,
) -> AnyDateInner
fn date_to_any( &self, d: &<Hijri<TabularAlgorithm> as Calendar>::DateInner, ) -> AnyDateInner
AnyDateInner Read moreSource§impl IntoAnyCalendar for Hijri<UmmAlQura>
impl IntoAnyCalendar for Hijri<UmmAlQura>
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<Hijri<UmmAlQura>, AnyCalendar>
fn from_any(any: AnyCalendar) -> Result<Hijri<UmmAlQura>, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<UmmAlQura>>
fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<UmmAlQura>>
impl<S> Copy for Hijri<S>where
S: Copy,
impl IntoFormattableAnyCalendar for Hijri<AstronomicalSimulation>
impl IntoFormattableAnyCalendar for Hijri<TabularAlgorithm>
impl IntoFormattableAnyCalendar for Hijri<UmmAlQura>
impl<R> UnstableSealed for Hijri<R>where
R: Rules,
Auto Trait Implementations§
impl<S> Freeze for Hijri<S>where
S: Freeze,
impl<S> RefUnwindSafe for Hijri<S>where
S: RefUnwindSafe,
impl<S> Send for Hijri<S>where
S: Send,
impl<S> Sync for Hijri<S>where
S: Sync,
impl<S> Unpin for Hijri<S>where
S: Unpin,
impl<S> UnwindSafe for Hijri<S>where
S: 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