pub(crate) struct ValidMonthCode {
number: u8,
is_leap: bool,
}Expand description
A MonthCode that has been parsed into its internal representation.
Fields§
§number: u8Month number between 0 and 99
is_leap: boolImplementations§
Source§impl ValidMonthCode
impl ValidMonthCode
pub(crate) fn try_from_utf8(bytes: &[u8]) -> Result<Self, MonthCodeParseError>
Sourcepub(crate) const fn new_unchecked(number: u8, is_leap: bool) -> Self
pub(crate) const fn new_unchecked(number: u8, is_leap: bool) -> Self
Create a new ValidMonthCode without checking that the number is between 1 and 99
Sourcepub fn number(self) -> u8
pub fn number(self) -> u8
Returns the month number according to the month code.
This is NOT the same as the ordinal month!
§Examples
ⓘ
use icu::calendar::Date;
use icu::calendar::cal::Hebrew;
let hebrew_date = Date::try_new_iso(2024, 7, 1).unwrap().to_calendar(Hebrew);
let month_info = hebrew_date.month();
// Hebrew year 5784 was a leap year, so the ordinal month and month number diverge.
assert_eq!(month_info.ordinal, 10);
assert_eq!(month_info.valid_month_code.number(), 9);Sourcepub fn is_leap(self) -> bool
pub fn is_leap(self) -> bool
Returns whether the month is a leap month.
This is true for intercalary months in Hebrew and LunarChinese.
pub(crate) fn to_tuple(self) -> (u8, bool)
pub(crate) fn to_month_code(self) -> MonthCode
Trait Implementations§
Source§impl Clone for ValidMonthCode
impl Clone for ValidMonthCode
Source§fn clone(&self) -> ValidMonthCode
fn clone(&self) -> ValidMonthCode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidMonthCode
impl Debug for ValidMonthCode
Source§impl PartialEq for ValidMonthCode
impl PartialEq for ValidMonthCode
Source§fn eq(&self, other: &ValidMonthCode) -> bool
fn eq(&self, other: &ValidMonthCode) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for ValidMonthCode
impl StructuralPartialEq for ValidMonthCode
Auto Trait Implementations§
impl Freeze for ValidMonthCode
impl RefUnwindSafe for ValidMonthCode
impl Send for ValidMonthCode
impl Sync for ValidMonthCode
impl Unpin for ValidMonthCode
impl UnsafeUnpin for ValidMonthCode
impl UnwindSafe for ValidMonthCode
Blanket Implementations§
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
Mutably borrows from an owned value. Read more