Enum datetime::Month
[−]
[src]
pub enum Month { January, February, March, April, May, June, July, August, September, October, November, December, }
A month of the year, starting with January, and ending with December.
This is stored as an enum instead of just a number to prevent
off-by-one errors: is month 2 February (1-indexed) or March (0-indexed)?
In this case, it’s 1-indexed, to have January become 1 when you use
as i32
in code.
Variants
January
February
March
April
May
June
July
August
September
October
November
December
Methods
impl Month
[src]
fn days_in_month(&self, leap_year: bool) -> i8
[src]
Returns the number of days in this month, depending on whether it’s a leap year or not.
fn months_from_january(&self) -> usize
[src]
fn from_one(month: i8) -> Result<Month, Error>
[src]
Returns the month based on a number, with January as Month 1, February as Month 2, and so on.
use datetime::Month; assert_eq!(Month::from_one(5), Ok(Month::May)); assert!(Month::from_one(0).is_err());
fn from_zero(month: i8) -> Result<Month, Error>
[src]
Returns the month based on a number, with January as Month 0, February as Month 1, and so on.
use datetime::Month; assert_eq!(Month::from_zero(5), Ok(Month::June)); assert!(Month::from_zero(12).is_err());
Trait Implementations
impl PartialEq for Month
[src]
fn eq(&self, __arg_0: &Month) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for Month
[src]
impl PartialOrd for Month
[src]
fn partial_cmp(&self, __arg_0: &Month) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Month
[src]
fn cmp(&self, __arg_0: &Month) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl Debug for Month
[src]
impl Clone for Month
[src]
fn clone(&self) -> Month
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more