#[repr(u8)]pub enum Month {
Jan = 1,
Feb = 2,
Mar = 3,
Apr = 4,
May = 5,
Jun = 6,
Jul = 7,
Aug = 8,
Sep = 9,
Oct = 10,
Nov = 11,
Dec = 12,
}Expand description
A month of the year, discriminant 1..=12.
Variants§
Jan = 1
January
Feb = 2
February
Mar = 3
March
Apr = 4
April
May = 5
May
Jun = 6
June
Jul = 7
July
Aug = 8
August
Sep = 9
September
Oct = 10
October
Nov = 11
November
Dec = 12
December
Implementations§
Source§impl Month
impl Month
Sourcepub const fn get(self) -> u8
pub const fn get(self) -> u8
Month number, Jan => 1, …, Dec => 12.
use fasti::Month;
assert_eq!(Month::Jul.get(), 7);Sourcepub const fn try_from_u8(month: u8) -> Result<Self, TimeError>
pub const fn try_from_u8(month: u8) -> Result<Self, TimeError>
Construct a Month from a 1-based month number, refusing
anything outside 1..=12.
use fasti::{Month, TimeError};
assert_eq!(Month::try_from_u8(7)?, Month::Jul);
assert_eq!(Month::try_from_u8(0), Err(TimeError::MonthOutOfRange));
assert_eq!(Month::try_from_u8(13), Err(TimeError::MonthOutOfRange));Sourcepub const fn length(self, year: Year) -> u8
pub const fn length(self, year: Year) -> u8
Number of days in this month for the given Year, with February
returning 28 or 29 as appropriate.
use fasti::{Month, Year};
assert_eq!(Month::Feb.length(Year::new(2024)?), 29); // leap
assert_eq!(Month::Feb.length(Year::new(2025)?), 28);
assert_eq!(Month::Apr.length(Year::new(2025)?), 30);Trait Implementations§
impl Copy for Month
Source§impl<'de> Deserialize<'de> for Month
impl<'de> Deserialize<'de> for Month
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Month
Source§impl Ord for Month
impl Ord for Month
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Month
impl PartialOrd 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 UnsafeUnpin 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