Module icu_calendar::japanese
source ยท Expand description
This module contains types and implementations for the Japanese calendar.
use icu::calendar::japanese::Japanese;
use icu::calendar::{types::Era, Date, DateTime};
use tinystr::tinystr;
let japanese_calendar = Japanese::new();
// `Date` type
let date_iso = Date::try_new_iso_date(1970, 1, 2)
.expect("Failed to initialize ISO Date instance.");
let date_japanese = Date::new_from_iso(date_iso, japanese_calendar.clone());
// `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_japanese =
DateTime::new_from_iso(datetime_iso, japanese_calendar.clone());
// `Date` checks
assert_eq!(date_japanese.year().number, 45);
assert_eq!(date_japanese.month().ordinal, 1);
assert_eq!(date_japanese.day_of_month().0, 2);
assert_eq!(date_japanese.year().era, Era(tinystr!(16, "showa")));
// `DateTime` type
assert_eq!(datetime_japanese.date.year().number, 45);
assert_eq!(datetime_japanese.date.month().ordinal, 1);
assert_eq!(datetime_japanese.date.day_of_month().0, 2);
assert_eq!(
datetime_japanese.date.year().era,
Era(tinystr!(16, "showa"))
);
assert_eq!(datetime_japanese.time.hour.number(), 13);
assert_eq!(datetime_japanese.time.minute.number(), 1);
assert_eq!(datetime_japanese.time.second.number(), 0);
Structsยง
- The Japanese Calendar (with modern eras only)
- The Japanese Calendar (with historical eras)
Constantsยง
- FALLBACK_ERA ๐
- HEISEI_START ๐
- MEIJI_START ๐
- REIWA_START ๐
- SHOWA_START ๐
- TAISHO_START ๐