pub struct Date { /* private fields */ }Expand description
Gregorian Date - a specific date on a calendar.
Implementations§
source§impl Date
impl Date
sourcepub fn new(
year: i32,
day_of_year: u16,
) -> Result<Date, GreaterThanEqualToValueError<u16>>
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.
sourcepub fn try_from_values(
year: i32,
month: u8,
day: u8,
) -> Result<Date, GreaterThanEqualToValueError<u8>>
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
sourcepub fn try_from(
year: i32,
month: Month,
day: u8,
) -> Result<Date, GreaterThanEqualToValueError<u8>>
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
sourcepub fn day_of_year_offset(&self) -> u16
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.
sourcepub fn day_of_year(&self) -> u16
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.
sourcepub fn month_of_year(&self) -> Month
pub fn month_of_year(&self) -> Month
Returns the Month this date is contained within
sourcepub fn day_of_month(&self) -> u8
pub fn day_of_month(&self) -> u8
Returns the day index into the current month in the range [0,31)
sourcepub fn sub_years(&self, years: u16) -> Date
pub fn sub_years(&self, years: u16) -> Date
Subtracts the specified number of years from this date.
sourcepub fn as_unix_timestamp(&self) -> UnixTimestamp
pub fn as_unix_timestamp(&self) -> UnixTimestamp
Returns the UnixTimestamp of this Date
sourcepub fn as_julian_day(&self) -> JulianDate
pub fn as_julian_day(&self) -> JulianDate
Returns the JulianDate of this date
sourcepub fn format<F: Format<Self>>(&self, format: &F) -> String
pub fn format<F: Format<Self>>(&self, format: &F) -> String
Formats this date using the specified formatter
sourcepub fn parse_from<F: FormatParser<Self>>(
format: &F,
string: &str,
) -> Result<Self, FormatError>
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
sourcepub fn day_of_week(&self) -> DayOfWeek
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.
sourcepub fn week_number(&self) -> (i32, u8)
pub fn week_number(&self) -> (i32, u8)
Returns a pair (year number, week of year)
Trait Implementations§
source§impl AddAssign<&Duration> for Date
impl AddAssign<&Duration> for Date
source§fn add_assign(&mut self, rhs: &Duration)
fn add_assign(&mut self, rhs: &Duration)
+= operation. Read moresource§impl AddAssign<Duration> for Date
impl AddAssign<Duration> for Date
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moresource§impl Format<Date> for BasicCalendarDate
impl Format<Date> for BasicCalendarDate
source§impl Format<Date> for ExtendedDateFormat
impl Format<Date> for ExtendedDateFormat
source§impl Format<Date> for ISO8601Date
impl Format<Date> for ISO8601Date
source§impl Format<Date> for ISO8601WeekNumber
impl Format<Date> for ISO8601WeekNumber
source§impl FormatParser<Date> for BasicCalendarDate
impl FormatParser<Date> for BasicCalendarDate
source§impl FormatParser<Date> for ExtendedDateFormat
impl FormatParser<Date> for ExtendedDateFormat
source§impl FormatParser<Date> for ISO8601Date
impl FormatParser<Date> for ISO8601Date
source§impl From<&Date> for JulianDate
impl From<&Date> for JulianDate
source§impl From<&Date> for UnixTimestamp
impl From<&Date> for UnixTimestamp
source§impl From<&JulianDayNumber<JulianEpoch>> for Date
impl From<&JulianDayNumber<JulianEpoch>> for Date
source§fn from(value: &JulianDate) -> Self
fn from(value: &JulianDate) -> Self
source§impl From<&Timestamp<UnixEpoch>> for Date
impl From<&Timestamp<UnixEpoch>> for Date
source§fn from(value: &UnixTimestamp) -> Self
fn from(value: &UnixTimestamp) -> Self
source§impl From<Date> for JulianDate
impl From<Date> for JulianDate
source§impl From<JulianDayNumber<JulianEpoch>> for Date
impl From<JulianDayNumber<JulianEpoch>> for Date
source§fn from(value: JulianDate) -> Self
fn from(value: JulianDate) -> Self
source§impl Ord for Date
impl Ord for Date
source§impl PartialOrd for Date
impl PartialOrd for Date
impl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Freeze for Date
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)