Module icu_calendar::hebrew

source ·
Expand description

This module contains types and implementations for the Hebrew calendar.

use icu::calendar::{hebrew::Hebrew, Date, DateTime, Ref};

let hebrew = Hebrew::new_always_calculating();
let hebrew = Ref(&hebrew); // to avoid cloning

// `Date` type
let hebrew_date =
    Date::try_new_hebrew_date_with_calendar(3425, 10, 11, hebrew)
        .expect("Failed to initialize hebrew Date instance.");

// `DateTime` type
let hebrew_datetime = DateTime::try_new_hebrew_datetime_with_calendar(
    3425, 10, 11, 13, 1, 0, hebrew,
)
.expect("Failed to initialize hebrew DateTime instance.");

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

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

Structs