Module icu_calendar::persian

source ·
Expand description

This module contains types and implementations for the Persian calendar.

use icu::calendar::{Date, DateTime};

// `Date` type
let persian_date = Date::try_new_persian_date(1348, 10, 11)
    .expect("Failed to initialize Persian Date instance.");

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

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

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

Structs§