Module icu_calendar::julian
source · Expand description
This module contains types and implementations for the Julian calendar.
use icu::calendar::{julian::Julian, Date, DateTime};
// `Date` type
let date_iso = Date::try_new_iso_date(1970, 1, 2)
.expect("Failed to initialize ISO Date instance.");
let date_julian = Date::new_from_iso(date_iso, Julian);
// `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_julian = DateTime::new_from_iso(datetime_iso, Julian);
// `Date` checks
assert_eq!(date_julian.year().number, 1969);
assert_eq!(date_julian.month().ordinal, 12);
assert_eq!(date_julian.day_of_month().0, 20);
// `DateTime` type
assert_eq!(datetime_julian.date.year().number, 1969);
assert_eq!(datetime_julian.date.month().ordinal, 12);
assert_eq!(datetime_julian.date.day_of_month().0, 20);
assert_eq!(datetime_julian.time.hour.number(), 13);
assert_eq!(datetime_julian.time.minute.number(), 1);
assert_eq!(datetime_julian.time.second.number(), 0);
Structs§
- The Julian Calendar