pub struct Year { /* private fields */ }
Expand description
A calendar year.
All dates in the library use the proleptic Gregorian calendar with a year 0.
Implementations
sourceimpl Year
impl Year
sourcepub const fn has_leap_day(self) -> bool
pub const fn has_leap_day(self) -> bool
Check if the year has a leap day.
In the proleptic Gregorian calendar with a year 0, the year 0 has a leap day.
sourcepub const fn total_days(self) -> u16
pub const fn total_days(self) -> u16
Get the total number of days in the year.
For leap years, this is 366. For other years, this is 365.
sourcepub const fn with_month(self, month: Month) -> YearMonth
pub const fn with_month(self, month: Month) -> YearMonth
Combine the year with a month to create a YearMonth
.
sourcepub const fn with_day_of_year(
self,
day_of_year: u16
) -> Result<Date, InvalidDayOfYear>
pub const fn with_day_of_year(
self,
day_of_year: u16
) -> Result<Date, InvalidDayOfYear>
Combine the year with a day-of-year to create a Date
.
Day-of-year numbers start a 1 for January 1.
sourcepub const fn first_month(self) -> YearMonth
pub const fn first_month(self) -> YearMonth
Get the first month of the year as YearMonth
.
sourcepub const fn last_month(self) -> YearMonth
pub const fn last_month(self) -> YearMonth
Get the last month of the year as YearMonth
.
Trait Implementations
sourceimpl AddAssign<i16> for Year
impl AddAssign<i16> for Year
sourcefn add_assign(&mut self, other: i16)
fn add_assign(&mut self, other: i16)
Performs the
+=
operation. Read moresourceimpl Ord for Year
impl Ord for Year
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Year> for Year
impl PartialOrd<Year> for Year
sourcefn partial_cmp(&self, other: &Year) -> Option<Ordering>
fn partial_cmp(&self, other: &Year) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl PartialOrd<i16> for Year
impl PartialOrd<i16> for Year
sourcefn partial_cmp(&self, other: &i16) -> Option<Ordering>
fn partial_cmp(&self, other: &i16) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl SubAssign<i16> for Year
impl SubAssign<i16> for Year
sourcefn sub_assign(&mut self, other: i16)
fn sub_assign(&mut self, other: i16)
Performs the
-=
operation. Read moreimpl Copy for Year
impl Eq for Year
impl StructuralEq for Year
impl StructuralPartialEq for Year
Auto Trait Implementations
impl RefUnwindSafe for Year
impl Send for Year
impl Sync for Year
impl Unpin for Year
impl UnwindSafe for Year
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more