Module icu_calendar::dangi

source ·
Expand description

This module contains types and implementations for the Korean Dangi calendar.

use icu::calendar::dangi::Dangi;
use icu::calendar::{Date, DateTime, Ref};

let dangi = Dangi::new();
let dangi = Ref(&dangi); // to avoid cloning

// `Date` type
let dangi_date = Date::try_new_dangi_date_with_calendar(4356, 6, 6, dangi)
    .expect("Failed to initialize Dangi Date instance.");

// `DateTime` type
let dangi_datetime = DateTime::try_new_dangi_datetime_with_calendar(
    4356, 6, 6, 13, 1, 0, dangi,
)
.expect("Failed to initialize Dangi DateTime instance.");

// `Date` checks
assert_eq!(dangi_date.year().number, 4356);
assert_eq!(dangi_date.year().related_iso, Some(2023));
assert_eq!(dangi_date.year().cyclic.unwrap().get(), 40);
assert_eq!(dangi_date.month().ordinal, 6);
assert_eq!(dangi_date.day_of_month().0, 6);

// `DateTime` checks
assert_eq!(dangi_datetime.date.year().number, 4356);
assert_eq!(dangi_datetime.date.year().related_iso, Some(2023));
assert_eq!(dangi_datetime.date.year().cyclic.unwrap().get(), 40);
assert_eq!(dangi_datetime.date.month().ordinal, 6);
assert_eq!(dangi_datetime.date.day_of_month().0, 6);
assert_eq!(dangi_datetime.time.hour.number(), 13);
assert_eq!(dangi_datetime.time.minute.number(), 1);
assert_eq!(dangi_datetime.time.second.number(), 0);

Structs§

Type Aliases§