Struct irox_time::gregorian::Date

source ·
pub struct Date { /* private fields */ }
Expand description

Gregorian Date - a specific date on a calendar.

Implementations§

source§

impl Date

source

pub fn new( year: i32, day_of_year: u16 ) -> Result<Date, GreaterThanEqualToValueError<u16>>

Constructs a new date given the provided gregorian year and day of year. Returns Err(GreaterThanEqualToValueError) if day_of_year is outside the valid range.

source

pub fn try_from_values( year: i32, month: u8, day: u8 ) -> Result<Date, GreaterThanEqualToValueError<u8>>

Constructs a new date given the provided values. If month or day is out of range, will return Err(OutsideRangeError).

Note: The ‘day’ parameter here is in the range of 1..=31 as would be shown on a calendar

source

pub fn try_from( year: i32, month: Month, day: u8 ) -> Result<Date, GreaterThanEqualToValueError<u8>>

Constructs a new date given the provided values, if day is out of range, will return Err(OutsideRangeError)

Note: The ‘day’ parameter here is in the range of 1..=31 as would be shown on a calendar

source

pub fn year(&self) -> i32

Returns the gregorian year this date represents

source

pub fn day_of_year_offset(&self) -> u16

Returns the day offset into the year. January 1 is ‘0’, January 31 is ‘30’, February 1 is ‘31’, and so on.

source

pub fn day_of_year(&self) -> u16

Returns the calendar day of the year. January 1 is ‘1’, January 31 is ‘31’, February 1 is ‘32’, and so on.

source

pub fn month_of_year(&self) -> Month

Returns the Month this date is contained within

source

pub fn day_of_month(&self) -> u8

Returns the day index into the current month in the range [0,31)

source

pub fn add_days(&self, days: u32) -> Date

Adds the specified number of days to this date.

source

pub fn sub_days(&self, days: u16) -> Date

Subtracts the given number of days from this date

source

pub fn add_years(&self, years: u16) -> Date

Adds the specified number of years to this date.

source

pub fn sub_years(&self, years: u16) -> Date

Subtracts the specified number of years from this date.

source

pub fn as_unix_timestamp(&self) -> UnixTimestamp

Returns the UnixTimestamp of this Date

source

pub fn as_julian_day(&self) -> JulianDate

Returns the JulianDate of this date

source

pub fn format<F: Format<Self>>(&self, format: &F) -> String

Formats this date using the specified formatter

source

pub fn parse_from<F: FormatParser<Self>>( format: &F, string: &str ) -> Result<Self, FormatError>

Attempts to parse a date from the string using the specified formatter

source

pub fn day_of_week(&self) -> DayOfWeek

Returns the day-of-the-week name of this date, using ISO8601 convention that the week starts on Monday.

source

pub fn week_number(&self) -> (i32, u8)

Returns a pair (year number, week of year)

Trait Implementations§

source§

impl Add<&Duration> for Date

§

type Output = Date

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Duration) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&mut Duration> for Date

§

type Output = Date

The resulting type after applying the + operator.
source§

fn add(self, rhs: &mut Duration) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Duration> for Date

§

type Output = Date

The resulting type after applying the + operator.
source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<&Duration> for Date

source§

fn add_assign(&mut self, rhs: &Duration)

Performs the += operation. Read more
source§

impl AddAssign<Duration> for Date

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl Clone for Date

source§

fn clone(&self) -> Date

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Date

source§

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

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

impl Default for Date

source§

fn default() -> Date

Returns the “default value” for a type. Read more
source§

impl Display for Date

source§

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

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

impl Format<Date> for BasicCalendarDate

source§

fn format(&self, date: &Date) -> String

Implementation-specific format of a date or time
source§

impl Format<Date> for ExtendedDateFormat

source§

fn format(&self, date: &Date) -> String

Implementation-specific format of a date or time
source§

impl Format<Date> for ISO8601Date

source§

fn format(&self, date: &Date) -> String

Implementation-specific format of a date or time
source§

impl Format<Date> for ISO8601WeekNumber

source§

fn format(&self, date: &Date) -> String

Implementation-specific format of a date or time
source§

impl FormatParser<Date> for BasicCalendarDate

source§

fn try_from(&self, data: &str) -> Result<Date, FormatError>

Tries to parse the specified string into the resultant item.
source§

impl FormatParser<Date> for ExtendedDateFormat

source§

fn try_from(&self, data: &str) -> Result<Date, FormatError>

Tries to parse the specified string into the resultant item.
source§

impl FormatParser<Date> for ISO8601Date

source§

fn try_from(&self, data: &str) -> Result<Date, FormatError>

Tries to parse the specified string into the resultant item.
source§

impl From<&Date> for JulianDate

source§

fn from(value: &Date) -> Self

Converts to this type from the input type.
source§

impl From<&Date> for UnixTimestamp

source§

fn from(value: &Date) -> Self

Converts to this type from the input type.
source§

impl From<&JulianDayNumber<JulianEpoch>> for Date

source§

fn from(value: &JulianDate) -> Self

Converts to this type from the input type.
source§

impl From<&Timestamp<UnixEpoch>> for Date

source§

fn from(value: &UnixTimestamp) -> Self

Converts to this type from the input type.
source§

impl From<Date> for JulianDate

source§

fn from(value: Date) -> Self

Converts to this type from the input type.
source§

impl From<JulianDayNumber<JulianEpoch>> for Date

source§

fn from(value: JulianDate) -> Self

Converts to this type from the input type.
source§

impl Ord for Date

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · source§

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

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

impl PartialEq for Date

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Date

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<&Date> for Date

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Date) -> Self::Output

Performs the - operation. Read more
source§

impl Sub for Date

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Date) -> Self::Output

Performs the - operation. Read more
source§

impl Copy for Date

source§

impl Eq for Date

source§

impl StructuralPartialEq for Date

Auto Trait Implementations§

§

impl RefUnwindSafe for Date

§

impl Send for Date

§

impl Sync for Date

§

impl Unpin for Date

§

impl UnwindSafe for Date

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> 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, U> MaybeInto<U> for T
where U: MaybeFrom<T>,

source§

fn maybe_into(self) -> Option<U>

source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.