#[non_exhaustive]pub struct MonthInfo {
pub ordinal: u8,
pub standard_code: MonthCode,
pub(crate) valid_standard_code: ValidMonthCode,
pub formatting_code: MonthCode,
pub(crate) valid_formatting_code: ValidMonthCode,
}Expand description
Representation of a formattable month.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.ordinal: u8The month number in this given year. For calendars with leap months, all months after the leap month will end up with an incremented number.
In general, prefer using the month code in generic code.
standard_code: MonthCodeThe month code, used to distinguish months during leap years.
Round-trips through Date constructors like Date::try_new_from_codes and Date::try_from_fields.
This follows Temporal’s specification. Months considered the “same” have the same code: This means that the Hebrew months “Adar” and “Adar II” (“Adar, but during a leap year”) are considered the same month and have the code M05.
valid_standard_code: ValidMonthCodeSame as Self::standard_code but with invariants validated.
formatting_code: MonthCodeA month code, useable for formatting.
Does NOT necessarily round-trip through Date constructors like Date::try_new_from_codes and Date::try_from_fields.
This may not necessarily be the canonical month code for a month in cases where a month has different formatting in a leap year, for example Adar/Adar II in the Hebrew calendar in a leap year has the standard code M06, but for formatting specifically the Hebrew calendar will return M06L since it is formatted differently.
valid_formatting_code: ValidMonthCodeSame as Self::formatting_code but with invariants validated.
Implementations§
Source§impl MonthInfo
impl MonthInfo
pub(crate) fn non_lunisolar(number: u8) -> Self
pub(crate) fn for_code_and_ordinal(code: ValidMonthCode, ordinal: u8) -> Self
Sourcepub fn month_number(self) -> u8
pub fn month_number(self) -> u8
Gets the month number. A month number N is not necessarily the Nth month in the year if there are leap months in the year, rather it is associated with the Nth month of a “regular” year. There may be multiple month Ns in a year