Module icu_calendar::islamic

source ยท
Expand description

This module contains types and implementations for the Islamic calendars.

use icu::calendar::islamic::IslamicObservational;
use icu::calendar::{Date, DateTime, Ref};

let islamic = IslamicObservational::new_always_calculating();
let islamic = Ref(&islamic); // to avoid cloning

// `Date` type
let islamic_date =
    Date::try_new_observational_islamic_date(1348, 10, 11, islamic)
        .expect("Failed to initialize islamic Date instance.");

// `DateTime` type
let islamic_datetime = DateTime::try_new_observational_islamic_datetime(
    1348, 10, 11, 13, 1, 0, islamic,
)
.expect("Failed to initialize islamic DateTime instance.");

// `Date` checks
assert_eq!(islamic_date.year().number, 1348);
assert_eq!(islamic_date.month().ordinal, 10);
assert_eq!(islamic_date.day_of_month().0, 11);

// `DateTime` checks
assert_eq!(islamic_datetime.date.year().number, 1348);
assert_eq!(islamic_datetime.date.month().ordinal, 10);
assert_eq!(islamic_datetime.date.day_of_month().0, 11);
assert_eq!(islamic_datetime.time.hour.number(), 13);
assert_eq!(islamic_datetime.time.minute.number(), 1);
assert_eq!(islamic_datetime.time.second.number(), 0);

Structsยง

Enumsยง

  • IslamicYearLength ๐Ÿ”’
    Compact representation of the length of an Islamic year.

Functionsยง

  • compute_month_day ๐Ÿ”’
    Given a year info and the first month it is possible for this date to be in, return the month and day this is in