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
impl ISOWeekDate
Sourcepub const MIN: ISOWeekDate
pub const MIN: ISOWeekDate
The maximum representable ISO week date.
Sourcepub const MAX: ISOWeekDate
pub const MAX: ISOWeekDate
The minimum representable ISO week date.
Sourcepub const ZERO: ISOWeekDate
pub const ZERO: ISOWeekDate
The zero ISO 8601 week date. It is the first day of the zeroth year.
Sourcepub const fn new(
year: i16,
week: i8,
weekday: Weekday,
) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub const fn new_constrain(
year: i16,
week: i8,
weekday: Weekday,
) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub const fn year(self) -> i16
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.
Sourcepub const fn week(self) -> i8
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.
Sourcepub const fn weekday(self) -> Weekday
pub const fn weekday(self) -> Weekday
Returns the weekday component of this ISO 8601 week date.
Sourcepub const fn first_of_week(self) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub const fn last_of_week(self) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub const fn first_of_year(self) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub const fn last_of_year(self) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub const fn days_in_year(self) -> i16
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.
Sourcepub const fn weeks_in_year(self) -> i8
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.
Sourcepub const fn in_long_year(self) -> bool
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.
Sourcepub const fn tomorrow(self) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub fn yesterday(self) -> Result<ISOWeekDate, RangeError>
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.
Sourcepub const fn to_unix_epoch_day(self) -> UnixEpochDay
pub const fn to_unix_epoch_day(self) -> UnixEpochDay
Converts this ISO 8601 week date to a Unix epoch day.
Trait Implementations§
Source§impl Clone for ISOWeekDate
impl Clone for ISOWeekDate
Source§fn clone(&self) -> ISOWeekDate
fn clone(&self) -> ISOWeekDate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more