Module chinese_based

Source
Expand description

This module contains types and traits for use in the Chinese traditional lunar calendar, as well as in related and derived calendars such as the Korean and Vietnamese lunar calendars.

use icu::calendar::{chinese::Chinese, Date, Iso};

let iso_date = Date::try_new_iso_date(2023, 6, 23).unwrap();
let chinese_date = Date::new_from_iso(iso_date, Chinese::new());

assert_eq!(chinese_date.year().number, 4660);
assert_eq!(chinese_date.year().related_iso, Some(2023));
assert_eq!(chinese_date.year().cyclic.unwrap().get(), 40);
assert_eq!(chinese_date.month().ordinal, 6);
assert_eq!(chinese_date.day_of_month().0, 6);

Structsยง

ChineseBasedDateInner ๐Ÿ”’
Chinese-based calendars define DateInner as a calendar-specific struct wrapping ChineseBasedDateInner.
ChineseBasedPrecomputedData ๐Ÿ”’
Contains any loaded precomputed data. If constructed with Default, will not contain any extra data and will always compute stuff from scratch
ChineseBasedYearInfo ๐Ÿ”’
A data struct used to load and use information for a set of ChineseBasedDates

Traitsยง

ChineseBasedWithDataLoading ๐Ÿ”’
The trait ChineseBased is used by Chinese-based calendars to perform computations shared by such calendar.

Functionsยง

chinese_based_ordinal_lunar_month_from_code ๐Ÿ”’
Get the ordinal lunar month from a code for chinese-based calendars.
compute_cache ๐Ÿ”’
Compute ChineseBasedYearInfo for a given extended year
compute_cache_with_yb ๐Ÿ”’
Compute ChineseBasedYearInfo for a given extended year, for which you have already computed the YearBounds
compute_packed_with_yb ๐Ÿ”’