# Enum chrono::Month [−] [src]

    pub enum Month {
        January,
        February,
        March,
        April,
        May,
        June,
        July,
        August,
        September,
        October,
        November,
        December,
    }

The month of the year.

This enum is just a convenience implementation. The month in dates created by DateLike objects does not return this enum.

It is possible to convert from a date to a month independently

    use num_traits::FromPrimitive;
    use chrono::prelude::*;
    let date = Utc.ymd(2019, 10, 28).and_hms(9, 10, 11);
    // `2019-10-28T09:10:11Z`
    let month = Month::from_u32(date.month());
    assert_eq!(month, Some(Month::October))

Or from a Month to an integer usable by dates

    let month = Month::January;
    let dt = Utc.ymd(2019, month.number_from_month(), 28).and_hms(9, 10, 11);
    assert_eq!((dt.year(), dt.month(), dt.day()), (2019, 1, 28));

Allows mapping from and to month, from 1-January to 12-December. Can be Serialized/Deserialized with serde

## Variants

`January`

January

`February`

February

`March`

March

`April`

April

`May`

May

`June`

June

`July`

July

`August`

August

`September`

September

`October`

October

`November`

November

`December`

December

## Implementations

### `impl Month` [src]

#### `pub fn succ(&self) -> Month` [src]

The next month.

`m`: | `January` | `February` | `...` | `December`
--- | --- | --- | --- | ---
`m.succ()`: | `February` | `March` | `...` | `January`

#### `pub fn pred(&self) -> Month` [src]

The previous month.

`m`: | `January` | `February` | `...` | `December`
--- | --- | --- | --- | ---
`m.succ()`: | `December` | `January` | `...` | `November`

#### `pub fn number_from_month(&self) -> u32` [src]

Returns a month-of-year number starting from January = 1.

`m`: | `January` | `February` | `...` | `December`
--- | --- | --- | --- | ---
`m.number_from_month()`: | 1 | 2 | `...` | 12

#### `pub fn name(&self) -> &'static str` [src]

Get the name of the month

    use chrono::Month;

    assert_eq!(Month::January.name(), "January")

## Trait Implementations

### `impl Clone for Month` [src]

#### `fn clone(&self) -> Month` [src]

Returns a copy of the value. Read more

#### `pub fn clone_from(&mut self, source: &Self)`1.0.0 [src]

Performs copy-assignment from `source`. Read more

### `impl Copy for Month` [src]

### `impl Debug for Month` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

### `impl Eq for Month` [src]

### `impl FromPrimitive for Month` [src]

#### `fn from_u64(n: u64) -> Option<Month>` [src]

Returns an Option<Month> from a i64, assuming a 1-index, January = 1.

`Month::from_i64(n: i64)`: | `1` | `2` | … | `12` —————————| –––––––––– | ——————— | … | —– ``: | Some(Month::January) | Some(Month::February) | … | Some(Month::December)

#### `fn from_i64(n: i64) -> Option<Month>` [src]

Converts an `i64` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `fn from_u32(n: u32) -> Option<Month>` [src]

Converts an `u32` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_isize(n: isize) -> Option<Self>` [src]

Converts an `isize` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_i8(n: i8) -> Option<Self>` [src]

Converts an `i8` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_i16(n: i16) -> Option<Self>` [src]

Converts an `i16` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_i32(n: i32) -> Option<Self>` [src]

Converts an `i32` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_i128(n: i128) -> Option<Self>` [src]

Converts an `i128` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_usize(n: usize) -> Option<Self>` [src]

Converts a `usize` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_u8(n: u8) -> Option<Self>` [src]

Converts an `u8` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_u16(n: u16) -> Option<Self>` [src]

Converts an `u16` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_u128(n: u128) -> Option<Self>` [src]

Converts an `u128` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_f32(n: f32) -> Option<Self>` [src]

Converts a `f32` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

#### `pub fn from_f64(n: f64) -> Option<Self>` [src]

Converts a `f64` to return an optional value of this type. If the value cannot be represented by this type, then `None` is returned. Read more

### `impl FromStr for Month` [src]

Parsing a `str` into a `Month` uses the format `%W`.

# Example

    use chrono::Month;

    assert_eq!("January".parse::<Month>(), Ok(Month::January));
    assert!("any day".parse::<Month>().is_err());

The parsing is case-insensitive.

    assert_eq!("fEbruARy".parse::<Month>(), Ok(Month::February));

Only the shortest form (e.g. `jan`) and the longest form (e.g. `january`) is accepted.

    assert!("septem".parse::<Month>().is_err());
    assert!("Augustin".parse::<Month>().is_err());

#### `type Err = ParseMonthError`

The associated error which can be returned from parsing.

#### `fn from_str(s: &str) -> Result<Self, Self::Err>` [src]

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

### `impl Hash for Month` [src]

#### `fn hash<__H: Hasher>(&self, state: &mut __H)` [src]

Feeds this value into the given `Hasher`. Read more

#### `pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,` 1.3.0 [src]

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

### `impl PartialEq<Month> for Month` [src]

#### `fn eq(&self, other: &Month) -> bool` [src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `#[must_use]pub fn ne(&self, other: &Rhs) -> bool` 1.0.0 [src]

This method tests for `!=`.

### `impl StructuralEq for Month` [src]

### `impl StructuralPartialEq for Month` [src]

## Auto Trait Implementations

### `impl RefUnwindSafe for Month`

### `impl Send for Month`

### `impl Sync for Month`

### `impl Unpin for Month`

### `impl UnwindSafe for Month`

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `pub fn to_owned(&self) -> T` [src]

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

#### `pub fn clone_into(&self, target: &mut T)` [src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

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

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

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

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.