Struct icu_calendar::japanese::Japanese
source · pub struct Japanese {
eras: DataPayload<JapaneseErasV1Marker>,
}
Expand description
The Japanese Calendar (with modern eras only)
The Japanese calendar is a solar calendar used in Japan, with twelve months. The months and days are identical to that of the Gregorian calendar, however the years are counted differently using the Japanese era system.
This calendar only contains eras after Meiji, for all historical eras, check out JapaneseExtended
.
This type can be used with Date
or DateTime
to represent dates in this calendar.
§Era codes
This calendar currently supports seven era codes. It supports the five post-Meiji eras
("meiji"
, "taisho"
, "showa"
, "heisei"
, "reiwa"
), as well as using the Gregorian
"bce"
and "ce"
for dates before the Meiji era.
Future eras will also be added to this type when they are decided.
These eras are loaded from data, requiring a data provider capable of providing JapaneseErasV1Marker
data (calendar/japanese@1
).
§Month codes
This calendar supports 12 solar month codes ("M01" - "M12"
)
Fields§
§eras: DataPayload<JapaneseErasV1Marker>
Implementations§
source§impl Japanese
impl Japanese
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new Japanese
using only modern eras (post-meiji) from compiled data.
✨ 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<JapaneseErasV1Marker> + ?Sized>(
provider: &D,
) -> Result<Self, CalendarError>
pub fn try_new_unstable<D: DataProvider<JapaneseErasV1Marker> + ?Sized>( provider: &D, ) -> Result<Self, CalendarError>
A version of Self::new
that uses custom data provided by a DataProvider
.
fn japanese_date_from_codes( &self, era: Era, year: i32, month_code: MonthCode, day: u8, debug_name: &'static str, ) -> Result<JapaneseDateInner, CalendarError>
pub(crate) const DEBUG_NAME: &'static str = "Japanese"
source§impl Japanese
impl Japanese
sourcefn adjusted_year_for(&self, date: &IsoDateInner) -> (i32, TinyStr16)
fn adjusted_year_for(&self, date: &IsoDateInner) -> (i32, TinyStr16)
Given an ISO date, give year and era for that date in the Japanese calendar
This will also use Gregorian eras for eras that are before the earliest era
sourcefn japanese_era_for(&self, date: EraStartDate) -> (EraStartDate, TinyStr16)
fn japanese_era_for(&self, date: EraStartDate) -> (EraStartDate, TinyStr16)
Given an date, obtain the era data (not counting spliced gregorian eras)
sourcefn japanese_era_range_for(
&self,
era: TinyStr16,
) -> Result<(EraStartDate, Option<EraStartDate>), CalendarError>
fn japanese_era_range_for( &self, era: TinyStr16, ) -> Result<(EraStartDate, Option<EraStartDate>), CalendarError>
Returns the range of dates for a given Japanese era code, not handling “bce” or “ce”
Returns (era_start, era_end)
fn new_japanese_date_inner( &self, era: Era, year: i32, month: u8, day: u8, ) -> Result<JapaneseDateInner, CalendarError>
Trait Implementations§
source§impl Calendar for Japanese
impl Calendar for Japanese
source§fn year(&self, date: &Self::DateInner) -> FormattableYear
fn year(&self, date: &Self::DateInner) -> FormattableYear
The calendar-specific year represented by date
source§fn month(&self, date: &Self::DateInner) -> FormattableMonth
fn month(&self, date: &Self::DateInner) -> FormattableMonth
The calendar-specific month represented by date
source§fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
The calendar-specific day-of-month represented by date
source§fn day_of_year_info(&self, date: &Self::DateInner) -> DayOfYearInfo
fn day_of_year_info(&self, date: &Self::DateInner) -> DayOfYearInfo
Information of the day of the year
§type DateInner = JapaneseDateInner
type DateInner = JapaneseDateInner
source§fn date_from_codes(
&self,
era: Era,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<Self::DateInner, CalendarError>
fn date_from_codes( &self, era: Era, year: i32, month_code: MonthCode, day: u8, ) -> Result<Self::DateInner, CalendarError>
source§fn date_from_iso(&self, iso: Date<Iso>) -> JapaneseDateInner
fn date_from_iso(&self, iso: Date<Iso>) -> JapaneseDateInner
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 is_in_leap_year(&self, date: &Self::DateInner) -> bool
fn is_in_leap_year(&self, date: &Self::DateInner) -> bool
source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
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§fn day_of_week(&self, date: &Self::DateInner) -> IsoWeekday
fn day_of_week(&self, date: &Self::DateInner) -> IsoWeekday
source§impl IntoAnyCalendar for Japanese
impl IntoAnyCalendar for Japanese
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 more