[−][src]Struct gregorian::YearMonth
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]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for YearMonth
[src]
pub fn cmp(&self, other: &YearMonth) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<YearMonth> for YearMonth
[src]
impl PartialOrd<YearMonth> for YearMonth
[src]
pub fn partial_cmp(&self, other: &YearMonth) -> Option<Ordering>
[src]
pub fn lt(&self, other: &YearMonth) -> bool
[src]
pub fn le(&self, other: &YearMonth) -> bool
[src]
pub fn gt(&self, other: &YearMonth) -> bool
[src]
pub fn ge(&self, other: &YearMonth) -> bool
[src]
impl StructuralEq for YearMonth
[src]
impl StructuralPartialEq for YearMonth
[src]
Auto Trait Implementations
impl RefUnwindSafe for YearMonth
[src]
impl Send for YearMonth
[src]
impl Sync for YearMonth
[src]
impl Unpin for YearMonth
[src]
impl UnwindSafe for YearMonth
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
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,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,