pub struct Dangi { /* private fields */ }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());
let chinese_a = iso_a.to_calendar(Chinese::new());
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());
let chinese_b = iso_b.to_calendar(Chinese::new());
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§
Source§impl Dangi
impl Dangi
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new Dangi with some precomputed calendrical calculations.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
) -> Result<Self, CalendarError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<Self, CalendarError>
A version of [Self :: new] that uses custom data provided by an AnyProvider.
Sourcepub fn try_new_unstable<D: DataProvider<DangiCacheV1Marker> + ?Sized>(
provider: &D,
) -> Result<Self, CalendarError>
pub fn try_new_unstable<D: DataProvider<DangiCacheV1Marker> + ?Sized>( provider: &D, ) -> Result<Self, CalendarError>
A version of Self::new that uses custom data provided by a DataProvider.
Sourcepub fn new_always_calculating() -> Self
pub fn new_always_calculating() -> Self
Construct a new Dangi without any precomputed calendrical calculations.
Trait Implementations§
Source§impl Calendar for Dangi
impl Calendar for Dangi
Source§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
dateSource§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
dateSource§fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
dateSource§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 NoneSource§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 PartialOrd for Dangi
impl PartialOrd for Dangi
impl Eq for Dangi
Auto Trait Implementations§
impl Freeze for Dangi
impl RefUnwindSafe for Dangi
impl !Send for Dangi
impl !Sync for Dangi
impl Unpin for Dangi
impl UnwindSafe for Dangi
Blanket Implementations§
Source§impl<C> AsCalendar for Cwhere
C: Calendar,
impl<C> AsCalendar for Cwhere
C: Calendar,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes