Module icu_calendar::iso
source · Expand description
This module contains types and implementations for the ISO calendar.
use icu::calendar::{Date, DateTime};
// `Date` type
let date_iso = Date::try_new_iso_date(1970, 1, 2)
.expect("Failed to initialize ISO Date instance.");
// `DateTime` type
let datetime_iso = DateTime::try_new_iso_datetime(1970, 1, 2, 13, 1, 0)
.expect("Failed to initialize ISO DateTime instance.");
// `Date` checks
assert_eq!(date_iso.year().number, 1970);
assert_eq!(date_iso.month().ordinal, 1);
assert_eq!(date_iso.day_of_month().0, 2);
// `DateTime` type
assert_eq!(datetime_iso.date.year().number, 1970);
assert_eq!(datetime_iso.date.month().ordinal, 1);
assert_eq!(datetime_iso.date.day_of_month().0, 2);
assert_eq!(datetime_iso.time.hour.number(), 13);
assert_eq!(datetime_iso.time.minute.number(), 1);
assert_eq!(datetime_iso.time.second.number(), 0);
Structs§
- The ISO Calendar