time::month

Enum Month

Source
#[repr(u8)]
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

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§

Source§

impl Month

Source

pub(crate) const fn from_number(n: NonZeroU8) -> Result<Self, ComponentRange>

Create a Month from its numerical value.

Source

pub const fn length(self, year: i32) -> u8

Get the number of days in the month of a given year.

assert_eq!(Month::February.length(2020), 29);
Source

pub const fn previous(self) -> Self

Get the previous month.

assert_eq!(Month::January.previous(), Month::December);
Source

pub const fn next(self) -> Self

Get the next month.

assert_eq!(Month::January.next(), Month::February);
Source

pub const fn nth_next(self, n: u8) -> Self

Get n-th next month.

assert_eq!(Month::January.nth_next(4), Month::May);
assert_eq!(Month::July.nth_next(9), Month::April);
Source

pub const fn nth_prev(self, n: u8) -> Self

Get n-th previous month.

assert_eq!(Month::January.nth_prev(4), Month::September);
assert_eq!(Month::July.nth_prev(9), Month::October);

Trait Implementations§

Source§

impl Arbitrary for Month

Available on crate feature quickcheck only.
Source§

fn arbitrary(g: &mut Gen) -> Self

Return an arbitrary value. Read more
Source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
Source§

impl Clone for Month

Source§

fn clone(&self) -> Month

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Month

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Deserialize<'a> for Month

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

#[doc(hidden)] fn deserialize_in_place<D>( deserializer: D, place: &mut Self, ) -> Result<(), <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserializes a value into self from the given Deserializer. Read more
Source§

impl Display for Month

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Distribution<Month> for Standard

Available on crate feature rand only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Month

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl Eq for Month

Source§

#[doc(hidden)] fn assert_receiver_is_total_eq(&self)

Source§

impl From<Month> for u8

Source§

fn from(month: Month) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Month

Source§

type Err = InvalidVariant

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Month

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Month

Source§

fn eq(&self, other: &Month) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Month

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl SmartDisplay for Month

Source§

type Metadata = MonthMetadata

User-provided metadata type.
Source§

fn metadata(&self, _: FormatterOptions) -> Metadata<'_, Self>

Compute any information needed to format the value. This must, at a minimum, determine the width of the value before any padding is added by the formatter. Read more
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Format the value using the given formatter. This is the same as Display::fmt. Read more
Source§

fn fmt_with_metadata( &self, f: &mut Formatter<'_>, _metadata: Metadata<'_, Self>, ) -> Result<(), Error>

Format the value using the given formatter and metadata. The formatted output should have the width indicated by the metadata. This is before any padding is added by the formatter. Read more
Source§

impl TryFrom<u8> for Month

Source§

type Error = ComponentRange

The type returned in the event of a conversion error.
Source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Month

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)] const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)] const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Printable for T
where T: Copy + Debug,