pub struct Date { /* private fields */ }Expand description
A calendar date.
Implementations§
Source§impl Date
impl Date
Sourcepub fn new(year: i64, month: u8, day: u8) -> Result<Date, DateError>
pub fn new(year: i64, month: u8, day: u8) -> Result<Date, DateError>
Construct a new Date from a year, month and day. The Calendar is inferred from the input fields.
§Errors
- DateError::InvalidDate if the input fields do not represent a valid date.
Sourcepub fn from_iso(iso: &str) -> Result<Date, DateError>
pub fn from_iso(iso: &str) -> Result<Date, DateError>
Constructs a new Date from an ISO 8601 string.
§Errors
- DateError::InvalidIsoString if the input string does not contain a valid ISO 8601 date.
- DateError::InvalidDate if the date parsed from the ISO 8601 string is invalid.
Sourcepub fn from_days_since_j2000(days: i64) -> Date
pub fn from_days_since_j2000(days: i64) -> Date
Sourcepub fn from_seconds_since_j2000(seconds: i64) -> Date
pub fn from_seconds_since_j2000(seconds: i64) -> Date
Sourcepub fn from_day_of_year(year: i64, day_of_year: u16) -> Result<Date, DateError>
pub fn from_day_of_year(year: i64, day_of_year: u16) -> Result<Date, DateError>
Constructs a new Date from a year and a day number within that year. The Calendar is inferred.
§Errors
- DateError::NonLeapYear if the input day number is 366 and the year is not a leap year.
Sourcepub const fn j2000_day_number(&self) -> i64
pub const fn j2000_day_number(&self) -> i64
Returns the day number of self relative to J2000.
Trait Implementations§
Source§impl JulianDate for Date
impl JulianDate for Date
Source§fn two_part_julian_date(&self) -> (f64, f64)
fn two_part_julian_date(&self) -> (f64, f64)
Source§fn seconds_since_julian_epoch(&self) -> f64
fn seconds_since_julian_epoch(&self) -> f64
Returns the number of seconds since the Julian epoch as an
f64.Source§fn seconds_since_modified_julian_epoch(&self) -> f64
fn seconds_since_modified_julian_epoch(&self) -> f64
Returns the number of seconds since the Modified Julian epoch as an
f64.Source§fn seconds_since_j1950(&self) -> f64
fn seconds_since_j1950(&self) -> f64
Returns the number of seconds since J1950 as an
f64.Source§fn seconds_since_j2000(&self) -> f64
fn seconds_since_j2000(&self) -> f64
Returns the number of seconds since J2000 as an
f64.Source§fn days_since_julian_epoch(&self) -> f64
fn days_since_julian_epoch(&self) -> f64
Returns the number of days since the Julian epoch as an
f64.Source§fn days_since_modified_julian_epoch(&self) -> f64
fn days_since_modified_julian_epoch(&self) -> f64
Returns the number of days since the Modified Julian epoch as an
f64.Source§fn days_since_j1950(&self) -> f64
fn days_since_j1950(&self) -> f64
Returns the number of days since J1950 as an
f64.Source§fn days_since_j2000(&self) -> f64
fn days_since_j2000(&self) -> f64
Returns the number of days since J2000 as an
f64.Source§fn years_since_julian_epoch(&self) -> f64
fn years_since_julian_epoch(&self) -> f64
Returns the number of years since the Julian epoch as an
f64.Source§fn years_since_modified_julian_epoch(&self) -> f64
fn years_since_modified_julian_epoch(&self) -> f64
Returns the number of years since the Modified Julian epoch as an
f64.Source§fn years_since_j1950(&self) -> f64
fn years_since_j1950(&self) -> f64
Returns the number of years since J1950 as an
f64.Source§fn years_since_j2000(&self) -> f64
fn years_since_j2000(&self) -> f64
Returns the number of years since J2000 as an
f64.Source§fn centuries_since_julian_epoch(&self) -> f64
fn centuries_since_julian_epoch(&self) -> f64
Returns the number of centuries since the Julian epoch as an
f64.Source§fn centuries_since_modified_julian_epoch(&self) -> f64
fn centuries_since_modified_julian_epoch(&self) -> f64
Returns the number of centuries since the Modified Julian epoch as an
f64.Source§fn centuries_since_j1950(&self) -> f64
fn centuries_since_j1950(&self) -> f64
Returns the number of centuries since J1950 as an
f64.Source§fn centuries_since_j2000(&self) -> f64
fn centuries_since_j2000(&self) -> f64
Returns the number of centuries since J2000 as an
f64.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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more