Hijri

Struct Hijri 

Source
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: S

Implementations§

Source§

impl Hijri<AstronomicalSimulation>

Source

pub const fn new_mecca() -> Hijri<AstronomicalSimulation>

👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
Source

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.

Source

pub 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

A version of Self::new that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

Source

pub 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

A version of Self::new_mecca that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
Source

pub const fn new_mecca_always_calculating() -> Hijri<AstronomicalSimulation>

👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
Source§

impl Hijri<UmmAlQura>

Source

pub const fn new() -> Hijri<UmmAlQura>

👎Deprecated since 2.1.0: use Self::new_umm_al_qura
Source

pub const fn new_umm_al_qura() -> Hijri<UmmAlQura>

Creates a Hijri calendar using UmmAlQura rules.

Source§

impl Hijri<TabularAlgorithm>

Source

pub const fn new( leap_years: TabularAlgorithmLeapYears, epoch: TabularAlgorithmEpoch, ) -> Hijri<TabularAlgorithm>

👎Deprecated since 2.1.0: use Hijri::new_tabular
Source

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,

Source§

type DateInner = HijriDateInner<R>

The internal type used to represent dates Read more
Source§

type Year = EraYear

The type of YearInfo returned by the date
Source§

type DifferenceError = Infallible

The type of error returned by until
Source§

fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<<Hijri<R> as Calendar>::DateInner, DateError>

Construct a date from era/month codes and fields Read more
Source§

fn from_rata_die(&self, rd: RataDie) -> <Hijri<R> as Calendar>::DateInner

Construct the date from a RataDie
Source§

fn to_rata_die(&self, date: &<Hijri<R> as Calendar>::DateInner) -> RataDie

Obtain a RataDie from this date
Source§

fn has_cheap_iso_conversion(&self) -> bool

Whether 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

Count the number of months in a given year, specified by providing a date from that year
Source§

fn days_in_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u16

Count the number of days in a given year, specified by providing a date from that year
Source§

fn days_in_month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> u8

Count the number of days in a given month, specified by providing a date from that year/month
Source§

fn debug_name(&self) -> &'static str

Obtain a name for the calendar for debug printing
Source§

fn year_info( &self, date: &<Hijri<R> as Calendar>::DateInner, ) -> <Hijri<R> as Calendar>::Year

Information about the year
Source§

fn is_in_leap_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> bool

Calculate if a date is in a leap year
Source§

fn month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> MonthInfo

The calendar-specific month represented by date
Source§

fn day_of_month(&self, date: &<Hijri<R> as Calendar>::DateInner) -> DayOfMonth

The calendar-specific day-of-month represented by date
Source§

fn day_of_year(&self, date: &<Hijri<R> as Calendar>::DateInner) -> DayOfYear

Information of the day of the year
Source§

fn calendar_algorithm(&self) -> Option<CalendarAlgorithm>

Returns the CalendarAlgorithm that is required to match when parsing into this calendar. Read more
Source§

fn from_iso(&self, iso: IsoDateInner) -> Self::DateInner

Construct the date from an ISO date. Read more
Source§

fn to_iso(&self, date: &Self::DateInner) -> IsoDateInner

Obtain an ISO date from this date. Read more
Source§

fn extended_year(&self, date: &Self::DateInner) -> i32

Source§

impl<R> CldrCalendar for Hijri<R>

Source§

type YearNamesV1 = <R as FormattableHijriRules>::YearNamesV1

The data marker for loading year symbols for this calendar.
Source§

type MonthNamesV1 = <R as FormattableHijriRules>::MonthNamesV1

The data marker for loading month symbols for this calendar.
Source§

type SkeletaV1 = <R as FormattableHijriRules>::SkeletaV1

The data marker for loading skeleton patterns for this calendar.
Source§

impl<S> Clone for Hijri<S>
where S: Clone,

Source§

fn clone(&self) -> Hijri<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for Hijri<S>
where S: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<S> Default for Hijri<S>
where S: Default,

Source§

fn default() -> Hijri<S>

Returns the “default value” for a type. Read more
Source§

impl From<Hijri<AstronomicalSimulation>> for AnyCalendar

Source§

fn from(value: Hijri<AstronomicalSimulation>) -> AnyCalendar

Converts to this type from the input type.
Source§

impl From<Hijri<TabularAlgorithm>> for AnyCalendar

Source§

fn from(value: Hijri<TabularAlgorithm>) -> AnyCalendar

Converts to this type from the input type.
Source§

impl From<Hijri<UmmAlQura>> for AnyCalendar

Source§

fn from(value: Hijri<UmmAlQura>) -> AnyCalendar

Converts to this type from the input type.
Source§

impl IntoAnyCalendar for Hijri<AstronomicalSimulation>

Source§

fn to_any(self) -> AnyCalendar

Convert this calendar into an AnyCalendar, moving it Read more
Source§

fn kind(&self) -> AnyCalendarKind

The AnyCalendarKind enum variant associated with this calendar
Source§

fn from_any( any: AnyCalendar, ) -> Result<Hijri<AstronomicalSimulation>, AnyCalendar>

Move an AnyCalendar into a Self, or returning it as an error if the types do not match. Read more
Source§

fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<AstronomicalSimulation>>

Convert an AnyCalendar reference into a Self reference. Read more
Source§

fn date_to_any( &self, d: &<Hijri<AstronomicalSimulation> as Calendar>::DateInner, ) -> AnyDateInner

Convert a date for this calendar into an AnyDateInner Read more
Source§

impl IntoAnyCalendar for Hijri<TabularAlgorithm>

Source§

fn to_any(self) -> AnyCalendar

Convert this calendar into an AnyCalendar, moving it Read more
Source§

fn kind(&self) -> AnyCalendarKind

The AnyCalendarKind enum variant associated with this calendar
Source§

fn from_any(any: AnyCalendar) -> Result<Hijri<TabularAlgorithm>, AnyCalendar>

Move an AnyCalendar into a Self, or returning it as an error if the types do not match. Read more
Source§

fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<TabularAlgorithm>>

Convert an AnyCalendar reference into a Self reference. Read more
Source§

fn date_to_any( &self, d: &<Hijri<TabularAlgorithm> as Calendar>::DateInner, ) -> AnyDateInner

Convert a date for this calendar into an AnyDateInner Read more
Source§

impl IntoAnyCalendar for Hijri<UmmAlQura>

Source§

fn to_any(self) -> AnyCalendar

Convert this calendar into an AnyCalendar, moving it Read more
Source§

fn kind(&self) -> AnyCalendarKind

The AnyCalendarKind enum variant associated with this calendar
Source§

fn from_any(any: AnyCalendar) -> Result<Hijri<UmmAlQura>, AnyCalendar>

Move an AnyCalendar into a Self, or returning it as an error if the types do not match. Read more
Source§

fn from_any_ref(any: &AnyCalendar) -> Option<&Hijri<UmmAlQura>>

Convert an AnyCalendar reference into a Self reference. Read more
Source§

fn date_to_any( &self, d: &<Hijri<UmmAlQura> as Calendar>::DateInner, ) -> AnyDateInner

Convert a date for this calendar into an AnyDateInner Read more
Source§

impl<S> Copy for Hijri<S>
where S: Copy,

Source§

impl IntoFormattableAnyCalendar for Hijri<AstronomicalSimulation>

Source§

impl IntoFormattableAnyCalendar for Hijri<TabularAlgorithm>

Source§

impl IntoFormattableAnyCalendar for Hijri<UmmAlQura>

Source§

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<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<C> AsCalendar for C
where C: Calendar,

Source§

type Calendar = C

The calendar being wrapped
Source§

fn as_calendar(&self) -> &C

Obtain the inner calendar
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetField<T> for T
where T: Copy + UnstableSealed,

Source§

fn get_field(&self) -> T

Returns the value of this trait’s field T.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,