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_simulated_mecca() -> Self
pub const fn new_simulated_mecca() -> Self
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_unstable<D: ?Sized>(
_provider: &D,
) -> Result<Self, DataError>
👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
pub fn try_new_mecca_unstable<D: ?Sized>( _provider: &D, ) -> Result<Self, DataError>
use Hijri::new_simulated_mecca
A version of Self::new_mecca that uses custom data provided by a DataProvider.
Sourcepub const fn new_mecca_always_calculating() -> Self
👎Deprecated since 2.1.0: use Hijri::new_simulated_mecca
pub const fn new_mecca_always_calculating() -> Self
use Hijri::new_simulated_mecca
Source§impl Hijri<UmmAlQura>
impl Hijri<UmmAlQura>
Sourcepub const fn new_umm_al_qura() -> Self
pub const fn new_umm_al_qura() -> Self
Source§impl Hijri<TabularAlgorithm>
impl Hijri<TabularAlgorithm>
Sourcepub const fn new(
leap_years: TabularAlgorithmLeapYears,
epoch: TabularAlgorithmEpoch,
) -> Self
👎Deprecated since 2.1.0: use Hijri::new_tabular
pub const fn new( leap_years: TabularAlgorithmLeapYears, epoch: TabularAlgorithmEpoch, ) -> Self
use Hijri::new_tabular
Sourcepub const fn new_tabular(
leap_years: TabularAlgorithmLeapYears,
epoch: TabularAlgorithmEpoch,
) -> Self
pub const fn new_tabular( leap_years: TabularAlgorithmLeapYears, epoch: TabularAlgorithmEpoch, ) -> Self
Creates a Hijri calendar with tabular rules and the given leap year rule and epoch.
Trait Implementations§
Source§impl<R: Rules> Calendar for Hijri<R>
impl<R: Rules> Calendar for Hijri<R>
Source§type DateInner = HijriDateInner<R>
type DateInner = HijriDateInner<R>
Source§type DifferenceError = Infallible
type DifferenceError = Infallible
untilSource§fn from_codes(
&self,
era: Option<&str>,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<Self::DateInner, DateError>
fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<Self::DateInner, DateError>
Source§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: &Self::DateInner) -> u8
fn months_in_year(&self, date: &Self::DateInner) -> u8
Source§fn days_in_year(&self, date: &Self::DateInner) -> u16
fn days_in_year(&self, date: &Self::DateInner) -> u16
Source§fn days_in_month(&self, date: &Self::DateInner) -> u8
fn days_in_month(&self, date: &Self::DateInner) -> u8
Source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
Source§fn is_in_leap_year(&self, date: &Self::DateInner) -> bool
fn is_in_leap_year(&self, date: &Self::DateInner) -> bool
Source§fn month(&self, date: &Self::DateInner) -> MonthInfo
fn month(&self, date: &Self::DateInner) -> MonthInfo
dateSource§fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
dateSource§fn day_of_year(&self, date: &Self::DateInner) -> DayOfYear
fn day_of_year(&self, date: &Self::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: Rules> DateFieldsResolver for Hijri<R>
impl<R: Rules> DateFieldsResolver for Hijri<R>
Source§type YearInfo = HijriYearData
type YearInfo = HijriYearData
fn days_in_provided_month(year: Self::YearInfo, month: u8) -> u8
fn months_in_provided_year(_year: Self::YearInfo) -> u8
Source§fn year_info_from_era(
&self,
era: &[u8],
era_year: i32,
) -> Result<Self::YearInfo, UnknownEraError>
fn year_info_from_era( &self, era: &[u8], era_year: i32, ) -> Result<Self::YearInfo, UnknownEraError>
Source§fn year_info_from_extended(&self, extended_year: i32) -> Self::YearInfo
fn year_info_from_extended(&self, extended_year: i32) -> Self::YearInfo
Source§fn reference_year_from_month_day(
&self,
month_code: ValidMonthCode,
day: u8,
) -> Result<Self::YearInfo, EcmaReferenceYearError>
fn reference_year_from_month_day( &self, month_code: ValidMonthCode, day: u8, ) -> Result<Self::YearInfo, EcmaReferenceYearError>
Source§fn ordinal_month_from_code(
&self,
_year: &Self::YearInfo,
month_code: ValidMonthCode,
_options: DateFromFieldsOptions,
) -> Result<u8, MonthCodeError>
fn ordinal_month_from_code( &self, _year: &Self::YearInfo, month_code: ValidMonthCode, _options: DateFromFieldsOptions, ) -> Result<u8, MonthCodeError>
Source§fn month_code_from_ordinal(
&self,
_year: &Self::YearInfo,
ordinal_month: u8,
) -> ValidMonthCode
fn month_code_from_ordinal( &self, _year: &Self::YearInfo, ordinal_month: u8, ) -> ValidMonthCode
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<Self, AnyCalendar>
fn from_any(any: AnyCalendar) -> Result<Self, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Self>
fn from_any_ref(any: &AnyCalendar) -> Option<&Self>
Source§fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner
fn date_to_any(&self, d: &Self::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<Self, AnyCalendar>
fn from_any(any: AnyCalendar) -> Result<Self, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Self>
fn from_any_ref(any: &AnyCalendar) -> Option<&Self>
Source§fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner
fn date_to_any(&self, d: &Self::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<Self, AnyCalendar>
fn from_any(any: AnyCalendar) -> Result<Self, AnyCalendar>
Source§fn from_any_ref(any: &AnyCalendar) -> Option<&Self>
fn from_any_ref(any: &AnyCalendar) -> Option<&Self>
Source§fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner
fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner
AnyDateInner Read more