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) -> u8

Get 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) -> Self

Get the previous month.

# use time::Month;
assert_eq!(Month::January.previous(), Month::December);
const fn next(self) -> Self

Get the next month.

# use time::Month;
assert_eq!(Month::January.next(), Month::February);
const fn nth_next(self, n: u8) -> Self

Get 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) -> Self

Get 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) -> MonthIter

Create 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>

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

impl<T> Any for Month where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Month where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Month where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Month where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Month

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Month where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for Month where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for Month where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Month where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Month where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>