pub struct Date { /* private fields */ }Expand description
Generic representation of date. Identifies an exact individual date within the calendar, in terms of days before (negative) or after (positive) 1970-01-01. This makes it useful as universal type that can be converted to and from other calendrical types.
Note that this type is not associated with a time zone: rather, it represents the local time in some implicit time zone.
It is explicitly not possible to subtract one Date from another to obtain a duration. This
choice is made to prevent errors due to leap seconds, which cannot be incorporated in a
purely calendrical type. Rather, a date must be mapped towards a proper time scale first,
before such arithmetic is possible. It is possible to add full days to a Date.
Implementations§
Source§impl Date
impl Date
Sourcepub const fn from_time_since_epoch(days: Days) -> Self
pub const fn from_time_since_epoch(days: Days) -> Self
Creates a date from the given number of days since 1970-01-01.
Sourcepub const fn time_since_epoch(&self) -> Days
pub const fn time_since_epoch(&self) -> Days
The number of days since the epoch of this representation - midnight 1970.
Sourcepub fn elapsed_calendar_days_since(self, other: Self) -> Days
pub fn elapsed_calendar_days_since(self, other: Self) -> Days
Returns the number of elapsed calendar days since the passed date. Beware: the returned value represents strictly the number of elapsed calendar (!) days. While it is expressed as a duration, the possibility of leap seconds is ignored. Only interpret the returned value as an exact duration if no leap seconds occurred between both days.
Source§impl Date
impl Date
Sourcepub const fn from_historic_date(
year: i32,
month: Month,
day: u8,
) -> Result<Self, InvalidHistoricDate>
pub const fn from_historic_date( year: i32, month: Month, day: u8, ) -> Result<Self, InvalidHistoricDate>
Creates a Date based on a year-month-day date in the historic calendar.
Sourcepub const fn from_gregorian_date(
year: i32,
month: Month,
day: u8,
) -> Result<Self, InvalidGregorianDate>
pub const fn from_gregorian_date( year: i32, month: Month, day: u8, ) -> Result<Self, InvalidGregorianDate>
Creates a Date based on a year-month-day date in the proleptic Gregorian calendar.
Sourcepub const fn from_julian_date(
year: i32,
month: Month,
day: u8,
) -> Result<Self, InvalidJulianDate>
pub const fn from_julian_date( year: i32, month: Month, day: u8, ) -> Result<Self, InvalidJulianDate>
Creates a Date based on a year-month-day date in the proleptic Julian calendar.
Trait Implementations§
Source§impl AddAssign<Days> for Date
impl AddAssign<Days> for Date
Source§fn add_assign(&mut self, rhs: Days)
fn add_assign(&mut self, rhs: Days)
+= operation. Read moreSource§impl From<Date> for GregorianDate
impl From<Date> for GregorianDate
Source§impl From<Date> for HistoricDate
impl From<Date> for HistoricDate
Source§impl From<Date> for JulianDate
impl From<Date> for JulianDate
Source§impl From<Date> for ModifiedJulianDate
impl From<Date> for ModifiedJulianDate
Source§impl From<GregorianDate> for Date
impl From<GregorianDate> for Date
Source§fn from(value: GregorianDate) -> Self
fn from(value: GregorianDate) -> Self
Source§impl From<HistoricDate> for Date
impl From<HistoricDate> for Date
Source§fn from(value: HistoricDate) -> Self
fn from(value: HistoricDate) -> Self
Source§impl From<JulianDate> for Date
impl From<JulianDate> for Date
Source§fn from(value: JulianDate) -> Self
fn from(value: JulianDate) -> Self
Source§impl From<ModifiedJulianDate> for Date
impl From<ModifiedJulianDate> for Date
Source§fn from(value: ModifiedJulianDate) -> Self
fn from(value: ModifiedJulianDate) -> Self
Source§impl Ord for Date
impl Ord for Date
Source§impl PartialOrd for Date
impl PartialOrd for Date
Source§impl SubAssign<Days> for Date
impl SubAssign<Days> for Date
Source§fn sub_assign(&mut self, rhs: Days)
fn sub_assign(&mut self, rhs: Days)
-= operation. Read more