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

Methods

impl Month
[src]

[src]

Returns the number of days in this month, depending on whether it’s a leap year or not.

[src]

[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());

[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]

[src]

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

1.0.0
[src]

This method tests for !=.

impl Eq for Month
[src]

impl PartialOrd for Month
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl Debug for Month
[src]

[src]

Formats the value using the given formatter.

impl Clone for Month
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Month
[src]