Struct icu_calendar::dangi::Dangi
source · #[non_exhaustive]pub struct Dangi;
Expand description
The Dangi Calendar
The Dangi Calendar is a lunisolar calendar used traditionally in North and South Korea.
It is often used today to track important cultural events and holidays like Seollal
(Korean lunar new year). It is similar to the Chinese lunar calendar (see Chinese
),
except that observations are based in Korea (currently UTC+9) rather than China (UTC+8).
This can cause some differences; for example, 2012 was a leap year, but in the Dangi
calendar the leap month was 3, while in the Chinese calendar the leap month was 4.
This calendar is currently in a preview state: formatting for this calendar is not going to be perfect.
use icu::calendar::{chinese::Chinese, dangi::Dangi, Date};
use tinystr::tinystr;
let iso_a = Date::try_new_iso_date(2012, 4, 23).unwrap();
let dangi_a = iso_a.to_calendar(Dangi::new_always_calculating());
let chinese_a = iso_a.to_calendar(Chinese::new_always_calculating());
assert_eq!(dangi_a.month().code.0, tinystr!(4, "M03L"));
assert_eq!(chinese_a.month().code.0, tinystr!(4, "M04"));
let iso_b = Date::try_new_iso_date(2012, 5, 23).unwrap();
let dangi_b = iso_b.to_calendar(Dangi::new_always_calculating());
let chinese_b = iso_b.to_calendar(Chinese::new_always_calculating());
assert_eq!(dangi_b.month().code.0, tinystr!(4, "M04"));
assert_eq!(chinese_b.month().code.0, tinystr!(4, "M04L"));
Era codes
This Calendar supports a single era code “dangi” based on the year -2332 ISO (2333 BCE) as year 1. Typically years will be formatted using cyclic years and the related ISO year.
Month codes
This calendar is a lunisolar calendar. It supports regular month codes "M01" - "M12"
as well
as leap month codes "M01L" - "M12L"
.
Implementations§
Trait Implementations§
source§impl Calendar for Dangi
impl Calendar for Dangi
§type DateInner = DangiDateInner
type DateInner = DangiDateInner
source§fn date_from_codes(
&self,
era: Era,
year: i32,
month_code: MonthCode,
day: u8
) -> Result<Self::DateInner, Error>
fn date_from_codes( &self, era: Era, year: i32, month_code: MonthCode, day: u8 ) -> Result<Self::DateInner, Error>
source§fn date_from_iso(&self, iso: Date<Iso>) -> Self::DateInner
fn date_from_iso(&self, iso: Date<Iso>) -> Self::DateInner
source§fn months_in_year(&self, date: &Self::DateInner) -> u8
fn months_in_year(&self, date: &Self::DateInner) -> u8
source§fn days_in_year(&self, date: &Self::DateInner) -> u16
fn days_in_year(&self, date: &Self::DateInner) -> u16
source§fn days_in_month(&self, date: &Self::DateInner) -> u8
fn days_in_month(&self, date: &Self::DateInner) -> u8
source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
source§fn year(&self, date: &Self::DateInner) -> FormattableYear
fn year(&self, date: &Self::DateInner) -> FormattableYear
date
source§fn is_in_leap_year(&self, date: &Self::DateInner) -> bool
fn is_in_leap_year(&self, date: &Self::DateInner) -> bool
source§fn month(&self, date: &Self::DateInner) -> FormattableMonth
fn month(&self, date: &Self::DateInner) -> FormattableMonth
date
source§fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
date
source§fn day_of_year_info(&self, date: &Self::DateInner) -> DayOfYearInfo
fn day_of_year_info(&self, date: &Self::DateInner) -> DayOfYearInfo
source§fn day_of_week(&self, date: &Self::DateInner) -> IsoWeekday
fn day_of_week(&self, date: &Self::DateInner) -> IsoWeekday
source§fn any_calendar_kind(&self) -> Option<AnyCalendarKind>
fn any_calendar_kind(&self) -> Option<AnyCalendarKind>
AnyCalendarKind
corresponding to this calendar,
if one exists. Implementors outside of icu_calendar
should return None
source§impl IntoAnyCalendar for Dangi
impl IntoAnyCalendar for Dangi
source§fn to_any(self) -> AnyCalendar
fn to_any(self) -> AnyCalendar
AnyCalendar
, moving it Read moresource§fn to_any_cloned(&self) -> AnyCalendar
fn to_any_cloned(&self) -> AnyCalendar
AnyCalendar
, cloning it Read moresource§fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner
fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner
AnyDateInner
Read moresource§impl Ord for Dangi
impl Ord for Dangi
source§impl PartialEq for Dangi
impl PartialEq for Dangi
source§impl PartialOrd for Dangi
impl PartialOrd for Dangi
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more