pub enum Month {
January = 1,
February = 2,
March = 3,
April = 4,
May = 5,
June = 6,
July = 7,
August = 8,
September = 9,
October = 10,
November = 11,
December = 12,
}
Expand description
A month of the year, starting with January, and ending with December.
This is stored as an enum instead of just a number to prevent
off-by-one errors: is month 2 February (1-indexed) or March (0-indexed)?
In this case, it’s 1-indexed, to have January become 1 when you use
as i32
in code.
Variants§
January = 1
February = 2
March = 3
April = 4
May = 5
June = 6
July = 7
August = 8
September = 9
October = 10
November = 11
December = 12
Implementations§
Source§impl Month
impl Month
Sourcepub fn days_in_month(self, leap_year: bool) -> i8
pub fn days_in_month(self, leap_year: bool) -> i8
Returns the number of days in this month, depending on whether it’s a leap year or not.
pub fn months_from_january(self) -> usize
Trait Implementations§
Source§impl Ord for Month
impl Ord for Month
Source§impl PartialOrd for Month
impl PartialOrd for Month
impl Copy for Month
impl Eq for Month
impl StructuralPartialEq for Month
Auto Trait Implementations§
impl Freeze for Month
impl RefUnwindSafe for Month
impl Send for Month
impl Sync for Month
impl Unpin for Month
impl UnwindSafe for Month
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
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)