Module icu_calendar::indian

source ·
Expand description

This module contains types and implementations for the Indian national calendar.

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

// `Date` type
let date_iso = Date::try_new_iso_date(1970, 1, 2)
    .expect("Failed to initialize ISO Date instance.");
let date_indian = Date::new_from_iso(date_iso, Indian);

// `DateTime` type
let datetime_iso = DateTime::try_new_iso_datetime(1970, 1, 2, 13, 1, 0)
    .expect("Failed to initialize ISO DateTime instance.");
let datetime_indian = DateTime::new_from_iso(datetime_iso, Indian);

// `Date` checks
assert_eq!(date_indian.year().number, 1891);
assert_eq!(date_indian.month().ordinal, 10);
assert_eq!(date_indian.day_of_month().0, 12);

// `DateTime` type
assert_eq!(datetime_indian.date.year().number, 1891);
assert_eq!(datetime_indian.date.month().ordinal, 10);
assert_eq!(datetime_indian.date.day_of_month().0, 12);
assert_eq!(datetime_indian.time.hour.number(), 13);
assert_eq!(datetime_indian.time.minute.number(), 1);
assert_eq!(datetime_indian.time.second.number(), 0);

Structs§