[][src]Struct gregorian::YearMonth

pub struct YearMonth { /* fields omitted */ }

A month of a specific year.

Implementations

impl YearMonth[src]

pub fn new(year: impl Into<Year>, month: Month) -> Self[src]

Create a new year-month.

pub const fn new_const(year: Year, month: Month) -> Self[src]

Create a new year-month at compile time.

Unline, Self::new(), this takes a Year instead of an impl Into<Year>, since the conversion can not be done in a const fn.

pub const fn year(self) -> Year[src]

Get the year.

pub const fn month(self) -> Month[src]

Get the month as Month.

pub const fn total_days(self) -> u8[src]

Get the total number of days in the month.

This function accounts for leap-days, so it reports 29 days for February of leap-years, and 28 days for other years.

pub const fn day_of_year(self) -> u16[src]

Get the day-of-year on which the month starts.

Day-of-year numbers are 1-based.

pub const fn next(self) -> Self[src]

Get the next month as YearMonth.

After December, this function returns January of the next year.

pub const fn prev(self) -> Self[src]

Get the previous month as YearMonth.

After January, this function returns December of the previous year.

pub const fn add_years(self, years: i16) -> Self[src]

Get a new YearMonth by adding a number of years.

pub const fn sub_years(self, years: i16) -> Self[src]

Get a new YearMonth by subtracting a number of years.

pub const fn add_months(self, months: i32) -> Self[src]

Get a new YearMonth by adding a number of months.

pub const fn sub_months(self, months: i32) -> Self[src]

Get a new YearMonth by subtracting a number of months.

pub const fn with_day(self, day: u8) -> Result<Date, InvalidDayOfMonth>[src]

Combine the year and month with a day, to create a full Date.

pub const unsafe fn with_day_unchecked(self, day: u8) -> Date[src]

Combine the year and month with a day, without checking for validity.

Safety

Although this is currently not the case, future implementations may rely on date validity for memory safety

pub const fn first_day(self) -> Date[src]

Get the first day of the month as Date.

pub const fn last_day(self) -> Date[src]

Get the last day of the month as Date.

Trait Implementations

impl Clone for YearMonth[src]

impl Copy for YearMonth[src]

impl Debug for YearMonth[src]

impl Display for YearMonth[src]

impl Eq for YearMonth[src]

impl Hash for YearMonth[src]

impl Ord for YearMonth[src]

impl PartialEq<YearMonth> for YearMonth[src]

impl PartialOrd<YearMonth> for YearMonth[src]

impl StructuralEq for YearMonth[src]

impl StructuralPartialEq for YearMonth[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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.

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.