Struct icu_calendar::dangi::Dangi
source · pub struct Dangi {
data: Option<DataPayload<DangiCacheV1Marker>>,
}
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"
.
Fields§
§data: Option<DataPayload<DangiCacheV1Marker>>
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.
pub(crate) const DEBUG_NAME: &'static str = "Dangi"
source§impl Dangi
impl Dangi
sourcefn format_dangi_year(
year: i32,
year_info_option: Option<ChineseBasedYearInfo>,
) -> FormattableYear
fn format_dangi_year( year: i32, year_info_option: Option<ChineseBasedYearInfo>, ) -> FormattableYear
Get a FormattableYear
from an integer Dangi year; optionally, a ChineseBasedYearInfo
can be passed in for faster results.
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
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 ChineseBasedWithDataLoading for Dangi
impl ChineseBasedWithDataLoading for Dangi
type CB = Dangi
source§fn get_precomputed_data(&self) -> ChineseBasedPrecomputedData<'_, Self::CB>
fn get_precomputed_data(&self) -> ChineseBasedPrecomputedData<'_, Self::CB>
None
if the given year
does not correspond to any compiled data.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 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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)