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::cal::{Chinese, Dangi};
use icu::calendar::Date;
use tinystr::tinystr;
let iso_a = Date::try_new_iso(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().standard_code.0, tinystr!(4, "M03L"));
assert_eq!(chinese_a.month().standard_code.0, tinystr!(4, "M04"));
let iso_b = Date::try_new_iso(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().standard_code.0, tinystr!(4, "M04"));
assert_eq!(chinese_b.month().standard_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() -> Dangi
pub const fn new() -> Dangi
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<Dangi, DataError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<Dangi, DataError>
A version of [Self :: new
] that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized),
) -> Result<Dangi, DataError>
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), ) -> Result<Dangi, DataError>
A version of [Self :: new
] that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub fn try_new_unstable<D>(provider: &D) -> Result<Dangi, DataError>
pub fn try_new_unstable<D>(provider: &D) -> Result<Dangi, DataError>
A version of Self::new
that uses custom data provided by a DataProvider
.
sourcepub fn new_always_calculating() -> Dangi
pub fn new_always_calculating() -> Dangi
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: Option<Era>,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<<Dangi as Calendar>::DateInner, DateError>
fn date_from_codes( &self, era: Option<Era>, year: i32, month_code: MonthCode, day: u8, ) -> Result<<Dangi as Calendar>::DateInner, DateError>
source§fn date_from_iso(&self, iso: Date<Iso>) -> <Dangi as Calendar>::DateInner
fn date_from_iso(&self, iso: Date<Iso>) -> <Dangi as Calendar>::DateInner
source§fn date_to_iso(&self, date: &<Dangi as Calendar>::DateInner) -> Date<Iso>
fn date_to_iso(&self, date: &<Dangi as Calendar>::DateInner) -> Date<Iso>
source§fn months_in_year(&self, date: &<Dangi as Calendar>::DateInner) -> u8
fn months_in_year(&self, date: &<Dangi as Calendar>::DateInner) -> u8
source§fn days_in_year(&self, date: &<Dangi as Calendar>::DateInner) -> u16
fn days_in_year(&self, date: &<Dangi as Calendar>::DateInner) -> u16
source§fn days_in_month(&self, date: &<Dangi as Calendar>::DateInner) -> u8
fn days_in_month(&self, date: &<Dangi as Calendar>::DateInner) -> u8
source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
source§fn is_in_leap_year(&self, date: &<Dangi as Calendar>::DateInner) -> bool
fn is_in_leap_year(&self, date: &<Dangi as Calendar>::DateInner) -> bool
source§fn month(&self, date: &<Dangi as Calendar>::DateInner) -> MonthInfo
fn month(&self, date: &<Dangi as Calendar>::DateInner) -> MonthInfo
date
source§fn day_of_month(&self, date: &<Dangi as Calendar>::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &<Dangi as Calendar>::DateInner) -> DayOfMonth
date
source§fn day_of_year_info(
&self,
date: &<Dangi as Calendar>::DateInner,
) -> DayOfYearInfo
fn day_of_year_info( &self, date: &<Dangi as Calendar>::DateInner, ) -> DayOfYearInfo
source§fn day_of_week(&self, date: &<Dangi as Calendar>::DateInner) -> IsoWeekday
fn day_of_week(&self, date: &<Dangi as Calendar>::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 CldrCalendar for Dangi
impl CldrCalendar for Dangi
source§type YearNamesV1Marker = DangiYearNamesV1Marker
type YearNamesV1Marker = DangiYearNamesV1Marker
source§type MonthNamesV1Marker = DangiMonthNamesV1Marker
type MonthNamesV1Marker = DangiMonthNamesV1Marker
source§type SkeletaV1Marker = DangiDateNeoSkeletonPatternsV1Marker
type SkeletaV1Marker = DangiDateNeoSkeletonPatternsV1Marker
source§impl From<Dangi> for AnyCalendar
impl From<Dangi> for AnyCalendar
source§fn from(value: Dangi) -> AnyCalendar
fn from(value: Dangi) -> AnyCalendar
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 kind(&self) -> AnyCalendarKind
fn kind(&self) -> AnyCalendarKind
AnyCalendarKind
enum variant associated with this calendarsource§fn to_any_cloned(&self) -> AnyCalendar
fn to_any_cloned(&self) -> AnyCalendar
AnyCalendar
, cloning it Read moresource§fn from_any(any: AnyCalendar) -> Result<Dangi, AnyCalendar>
fn from_any(any: AnyCalendar) -> Result<Dangi, AnyCalendar>
source§fn from_any_ref(any: &AnyCalendar) -> Option<&Dangi>
fn from_any_ref(any: &AnyCalendar) -> Option<&Dangi>
source§fn date_to_any(&self, d: &<Dangi as Calendar>::DateInner) -> AnyDateInner
fn date_to_any(&self, d: &<Dangi as Calendar>::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
impl UnstableSealed 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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more