Module icu_calendar::buddhist

source ·
Expand description

This module contains types and implementations for the Buddhist calendar.

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

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

// `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_buddhist = DateTime::new_from_iso(datetime_iso, Buddhist);

// `Date` checks
assert_eq!(date_buddhist.year().number, 2513);
assert_eq!(date_buddhist.month().ordinal, 1);
assert_eq!(date_buddhist.day_of_month().0, 2);

// `DateTime` type
assert_eq!(datetime_buddhist.date.year().number, 2513);
assert_eq!(datetime_buddhist.date.month().ordinal, 1);
assert_eq!(datetime_buddhist.date.day_of_month().0, 2);
assert_eq!(datetime_buddhist.time.hour.number(), 13);
assert_eq!(datetime_buddhist.time.minute.number(), 1);
assert_eq!(datetime_buddhist.time.second.number(), 0);

Structs§

Constants§

Functions§