Module icu_calendar::roc
source · Expand description
This module contains types and implementations for the Republic of China calendar.
use icu::calendar::{roc::Roc, Date, DateTime};
// `Date` type
let date_iso = Date::try_new_iso_date(1970, 1, 2)
.expect("Failed to initialize ISO Date instance.");
let date_roc = Date::new_from_iso(date_iso, Roc);
// `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_roc = DateTime::new_from_iso(datetime_iso, Roc);
// `Date` checks
assert_eq!(date_roc.year().number, 59);
assert_eq!(date_roc.month().ordinal, 1);
assert_eq!(date_roc.day_of_month().0, 2);
// `DateTime` checks
assert_eq!(datetime_roc.date.year().number, 59);
assert_eq!(datetime_roc.date.month().ordinal, 1);
assert_eq!(datetime_roc.date.day_of_month().0, 2);
assert_eq!(datetime_roc.time.hour.number(), 13);
assert_eq!(datetime_roc.time.minute.number(), 1);
assert_eq!(datetime_roc.time.second.number(), 0);
Structs§
- The Republic of China (ROC) Calendar
Constants§
- Year of the beginning of the Taiwanese (ROC/Minguo) calendar. 1912 ISO = ROC 1