Enum Month
#[repr(u8)]
pub enum Month
Months of the year.
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
impl Month
const fn length(self, year: i32) -> u8Get the number of days in the month of a given year.
# use time::Month; assert_eq!(Month::February.length(2020), 29);const fn previous(self) -> SelfGet the previous month.
# use time::Month; assert_eq!(Month::January.previous(), Month::December);const fn next(self) -> SelfGet the next month.
# use time::Month; assert_eq!(Month::January.next(), Month::February);const fn nth_next(self, n: u8) -> SelfGet n-th next month.
# use time::Month; assert_eq!(Month::January.nth_next(4), Month::May); assert_eq!(Month::July.nth_next(9), Month::April);const fn nth_prev(self, n: u8) -> SelfGet n-th previous month.
# use time::Month; assert_eq!(Month::January.nth_prev(4), Month::September); assert_eq!(Month::July.nth_prev(9), Month::October);const fn iter_from(start: Self) -> MonthIterCreate an infinite iterator starting at this month.
# use time::Month; let mut iter = Month::iter_from(Month::January); assert_eq!(iter.next(), Some(Month::January)); assert_eq!(iter.next(), Some(Month::February)); assert_eq!(iter.next(), Some(Month::March)); assert_eq!(iter.next(), Some(Month::April)); assert_eq!(iter.next(), Some(Month::May)); assert_eq!(iter.next(), Some(Month::June)); assert_eq!(iter.next(), Some(Month::July)); assert_eq!(iter.next(), Some(Month::August)); assert_eq!(iter.next(), Some(Month::September)); assert_eq!(iter.next(), Some(Month::October)); assert_eq!(iter.next(), Some(Month::November)); assert_eq!(iter.next(), Some(Month::December)); assert_eq!(iter.next(), Some(Month::January)); // … continuing forever
Trait Implementations
impl Clone for Month
fn clone(&self) -> Self
impl Copy for Month
impl Debug for Month
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for Month
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Month
impl FromStr for Month
type Err = InvalidVariant;fn from_str(s: &str) -> Result<Self, Self::Err>
impl Hash for Month
fn hash<__H: Hasher>(&self, state: &mut __H)
impl Ord for Month
fn cmp(&self, other: &Self) -> Ordering
impl PartialEq for Month
fn eq(&self, other: &Self) -> bool
impl PartialOrd for Month
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
impl SmartDisplay for Month
type Metadata = ();fn metadata(&self, FormatterOptions) -> Metadata<'_, Self>fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl StructuralPartialEq for Month
impl TryFrom<u8> for Month
type Error = ComponentRange;fn try_from(value: u8) -> Result<Self, Self::Error>