Enum Month
enum Month
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 *;
let date = Utc.with_ymd_and_hms.unwrap;
// `2019-10-28T09:10:11Z`
let month = try_from.ok;
assert_eq!
Or from a Month to an integer usable by dates
# use *;
let month = January;
let dt = Utc.with_ymd_and_hms.unwrap;
assert_eq!;
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
const fn succ(self: &Self) -> MonthThe next month.
m:JanuaryFebruary...Decemberm.succ():FebruaryMarch...Januaryconst fn pred(self: &Self) -> MonthThe previous month.
m:JanuaryFebruary...Decemberm.pred():DecemberJanuary...Novemberconst fn number_from_month(self: &Self) -> u32Returns a month-of-year number starting from January = 1.
m:JanuaryFebruary...Decemberm.number_from_month():1 2 ...12 const fn name(self: &Self) -> &'static strGet the name of the month
use Month; assert_eq!
impl Clone for Month
fn clone(self: &Self) -> Month
impl Copy for Month
impl Debug for Month
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Month
impl Freeze for Month
impl FromPrimitive for Month
fn from_u64(n: u64) -> Option<Month>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>fn from_u32(n: u32) -> Option<Month>
impl FromStr for Month
fn from_str(s: &str) -> Result<Self, <Self as >::Err>
impl Hash for Month
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl Ord for Month
fn cmp(self: &Self, other: &Month) -> Ordering
impl PartialEq for Month
fn eq(self: &Self, other: &Month) -> bool
impl PartialOrd for Month
fn partial_cmp(self: &Self, other: &Month) -> Option<Ordering>
impl RefUnwindSafe for Month
impl Send for Month
impl StructuralPartialEq for Month
impl Sync for Month
impl TryFrom for Month
fn try_from(value: u8) -> Result<Self, <Self as >::Error>
impl Unpin for Month
impl UnsafeUnpin for Month
impl UnwindSafe for Month
impl<T> Any for Month
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Month
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Month
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Month
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Month
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Month
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Month
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Month
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Month
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>