Skip to main content

ISOWeekDate

Struct ISOWeekDate 

Source
pub struct ISOWeekDate { /* private fields */ }
Expand description

An ISO 8601 civil week date.

An ISO 8601 civil week date can be infallibly converted to and from Gregorian Date values.

Implementations§

Source§

impl ISOWeekDate

Source

pub const MIN: ISOWeekDate

The maximum representable ISO week date.

Source

pub const MAX: ISOWeekDate

The minimum representable ISO week date.

Source

pub const ZERO: ISOWeekDate

The zero ISO 8601 week date. It is the first day of the zeroth year.

Source

pub 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.

Source

pub 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 return 9999 W52 Friday.

This still returns an error when week < 1 or when year is invalid.

Source

pub const fn year(self) -> i16

Returns the year component of this ISO 8601 week date.

The value returned is guaranteed to be in the range specified by ISOYear.

Source

pub const fn week(self) -> i8

Returns the week number component of this ISO 8601 week date.

The value returned is guaranteed to be in the range specified by ISOWeek.

Source

pub const fn weekday(self) -> Weekday

Returns the weekday component of this ISO 8601 week date.

Source

pub 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-01 falls 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 with ISOWeekDate::last_of_week, the API is fallible.

Source

pub 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 since 9999-12-31 falls on a Friday.

Source

pub 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-01 falls 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 with ISOWeekDate::last_of_year, the API is fallible.

Source

pub 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 since 9999-12-31 falls on a Friday.

Source

pub const fn days_in_year(self) -> i16

Returns 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_year returns true.

Source

pub const fn weeks_in_year(self) -> i8

Returns 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_year returns true.

Source

pub const fn in_long_year(self) -> bool

Returns 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.

Source

pub 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.

Source

pub 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.

Source

pub const fn to_unix_epoch_day(self) -> UnixEpochDay

Converts this ISO 8601 week date to a Unix epoch day.

Source

pub const fn to_date(self) -> Date

Converts this ISO 8601 week date to a Gregorian date.

Trait Implementations§

Source§

impl Clone for ISOWeekDate

Source§

fn clone(&self) -> ISOWeekDate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ISOWeekDate

Source§

impl Debug for ISOWeekDate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ISOWeekDate

Source§

impl Format for ISOWeekDate
where Weekday: Format,

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
Source§

impl Hash for ISOWeekDate

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ISOWeekDate

Source§

fn cmp(&self, other: &ISOWeekDate) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ISOWeekDate

Source§

fn eq(&self, other: &ISOWeekDate) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for ISOWeekDate

Source§

fn partial_cmp(&self, other: &ISOWeekDate) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for ISOWeekDate

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.