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
February
March
April
May
June
July
August
September
October
November
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][+]
impl Copy for Month
[src]
impl Debug for Month
[src][+]
impl<'de> Deserialize<'de> for Month
[src][+]
impl Eq for Month
[src]
impl FromPrimitive for Month
[src][+]
impl FromStr for Month
[src][+]
impl Hash for Month
[src][+]
impl PartialEq<Month> for Month
[src][+]
impl Serialize for Month
[src][+]
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][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,