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 more