Struct ISOWeekDate
pub struct ISOWeekDate { /* private fields */ }
An ISO 8601 civil week date.
An ISO 8601 civil week date can be infallibly converted to and from
Gregorian Date values.
Implementations
impl ISOWeekDate
const MIN: ISOWeekDate = _;The maximum representable ISO week date.
const MAX: ISOWeekDate = _;The minimum representable ISO week date.
const ZERO: ISOWeekDate = _;The zero ISO 8601 week date. It is the first day of the zeroth year.
const fn new(year: i16, week: i8, weekday: Weekday) -> Result<ISOWeekDate, RangeError>Create a new ISO week date from its constituent parts.
If the week date is invalid or any of the values are out of their supported ranges, then an error is returned.
const fn new_constrain(year: i16, week: i8, weekday: Weekday) -> Result<ISOWeekDate, RangeError>Like
ISOWeekDate::new, but constrains out-of-bounds week and weekday values to their closest valid equivalent.For example, given
9999 W52 Saturday, this will return9999 W52 Friday.This still returns an error when
week < 1or whenyearis invalid.const fn year(self) -> i16Returns the year component of this ISO 8601 week date.
The value returned is guaranteed to be in the range specified by
ISOYear.const fn week(self) -> i8Returns the week number component of this ISO 8601 week date.
The value returned is guaranteed to be in the range specified by
ISOWeek.const fn weekday(self) -> WeekdayReturns the weekday component of this ISO 8601 week date.
const fn first_of_week(self) -> Result<ISOWeekDate, RangeError>Returns the ISO 8601 week date corresponding to the first day in the week of this week date. The date returned is guaranteed to have a weekday of
Weekday::Monday.Errors
Since
-9999-01-01falls on a Monday, it follows that the minimum supported Gregorian date is exactly equivalent to the minimum supported ISO 8601 week date. This means that this routine can never actually fail, but only insomuch as the minimums line up. For that reason, and for consistency withISOWeekDate::last_of_week, the API is fallible.const fn last_of_week(self) -> Result<ISOWeekDate, RangeError>Returns the ISO 8601 week date corresponding to the last day in the week of this week date. The date returned is guaranteed to have a weekday of
Weekday::Sunday.Errors
This can return an error if the last day of the week exceeds Jiff's maximum Gregorian date of
9999-12-31. It turns out this can happen since9999-12-31falls on a Friday.const fn first_of_year(self) -> Result<ISOWeekDate, RangeError>Returns the ISO 8601 week date corresponding to the first day in the year of this week date. The date returned is guaranteed to have a weekday of
Weekday::Monday.Errors
Since
-9999-01-01falls on a Monday, it follows that the minimum support Gregorian date is exactly equivalent to the minimum supported ISO 8601 week date. This means that this routine can never actually fail, but only insomuch as the minimums line up. For that reason, and for consistency withISOWeekDate::last_of_year, the API is fallible.const fn last_of_year(self) -> Result<ISOWeekDate, RangeError>Returns the ISO 8601 week date corresponding to the last day in the year of this week date. The date returned is guaranteed to have a weekday of
Weekday::Sunday.Errors
This can return an error if the last day of the year exceeds Jiff's maximum Gregorian date of
9999-12-31. It turns out this can happen since9999-12-31falls on a Friday.const fn days_in_year(self) -> i16Returns the total number of days in the year of this ISO 8601 week date.
It is guaranteed that the value returned is either 364 or 371. The latter case occurs precisely when
ISOWeekDate::in_long_yearreturnstrue.const fn weeks_in_year(self) -> i8Returns the total number of weeks in the year of this ISO 8601 week date.
It is guaranteed that the value returned is either 52 or 53. The latter case occurs precisely when
ISOWeekDate::in_long_yearreturnstrue.const fn in_long_year(self) -> boolReturns true if and only if the year of this week date is a "long" year.
A long year is one that contains precisely 53 weeks. All other years contain precisely 52 weeks.
const fn tomorrow(self) -> Result<ISOWeekDate, RangeError>Returns the ISO 8601 date immediately following this one.
Errors
This returns an error when this date is the maximum value.
fn yesterday(self) -> Result<ISOWeekDate, RangeError>Returns the ISO 8601 week date immediately preceding this one.
Errors
This returns an error when this date is the minimum value.
const fn to_unix_epoch_day(self) -> UnixEpochDayConverts this ISO 8601 week date to a Unix epoch day.
const fn to_date(self) -> DateConverts this ISO 8601 week date to a Gregorian date.
Trait Implementations
impl Clone for ISOWeekDate
fn clone(&self) -> ISOWeekDate
impl Copy for ISOWeekDate
impl Debug for ISOWeekDate
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for ISOWeekDate
impl Hash for ISOWeekDate
fn hash<__H: Hasher>(&self, state: &mut __H)
impl Ord for ISOWeekDate
fn cmp(&self, other: &ISOWeekDate) -> Ordering
impl PartialEq for ISOWeekDate
fn eq(&self, other: &ISOWeekDate) -> bool
impl PartialOrd for ISOWeekDate
fn partial_cmp(&self, other: &ISOWeekDate) -> Option<Ordering>
impl StructuralPartialEq for ISOWeekDate
Auto Trait Implementations
impl Freeze for ISOWeekDate
impl RefUnwindSafe for ISOWeekDate
impl Send for ISOWeekDate
impl Sync for ISOWeekDate
impl Unpin for ISOWeekDate
impl UnsafeUnpin for ISOWeekDate
impl UnwindSafe for ISOWeekDate
Blanket Implementations
impl<T> Any for ISOWeekDate
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ISOWeekDate
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ISOWeekDate
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ISOWeekDate
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ISOWeekDate
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ISOWeekDate
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for ISOWeekDate
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ISOWeekDate
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for ISOWeekDate
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>