Skip to main content

Date

Struct Date 

Source
pub struct Date { /* private fields */ }
Expand description

A calendar date.

Implementations§

Source§

impl Date

Source

pub fn calendar(&self) -> Calendar

Returns the calendar system of this date.

Source

pub fn year(&self) -> i64

Returns the year.

Source

pub fn month(&self) -> u8

Returns the month (1–12).

Source

pub fn day(&self) -> u8

Returns the day of the month (1–31).

Source

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
Source

pub const fn new_unchecked(year: i64, month: u8, day: u8) -> Date

Constructs a new Date without validation. The Calendar is inferred.

Source

pub fn from_iso(iso: &str) -> Result<Date, DateError>

Constructs a new Date from an ISO 8601 string.

§Errors
Source

pub fn from_days_since_j2000(days: i64) -> Date

Constructs a new Date from a signed number of days since J2000. The Calendar is inferred.

Source

pub fn from_seconds_since_j2000(seconds: i64) -> Date

Constructs a new Date from a signed number of seconds since J2000. The Calendar is inferred.

Source

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
Source

pub const fn j2000_day_number(&self) -> i64

Returns the day number of self relative to J2000.

Source

pub const fn to_delta(&self) -> TimeDelta

Converts this date to a TimeDelta relative to J2000.

Trait Implementations§

Source§

impl Clone for Date

Source§

fn clone(&self) -> Date

Returns a duplicate 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<(), Error>

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

impl Default for Date

Source§

fn default() -> Date

Date defaults to 2000-01-01 of the Gregorian calendar.

Source§

impl Display for Date

Source§

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

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

impl FromStr for Date

Source§

type Err = DateError

The associated error which can be returned from parsing.
Source§

fn from_str(iso: &str) -> Result<Date, <Date as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl JulianDate for Date

Source§

fn julian_date(&self, epoch: Epoch, unit: Unit) -> f64

Expresses self as a Julian date in the specified Unit, relative to the given Epoch. Read more
Source§

fn two_part_julian_date(&self) -> (f64, f64)

Expresses self as a two-part Julian date in the specified Unit, relative to the given Epoch. Read more
Source§

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

Returns the number of seconds since the Modified Julian epoch as an f64.
Source§

fn seconds_since_j1950(&self) -> f64

Returns the number of seconds since J1950 as an f64.
Source§

fn seconds_since_j2000(&self) -> f64

Returns the number of seconds since J2000 as an f64.
Source§

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

Returns the number of days since the Modified Julian epoch as an f64.
Source§

fn days_since_j1950(&self) -> f64

Returns the number of days since J1950 as an f64.
Source§

fn days_since_j2000(&self) -> f64

Returns the number of days since J2000 as an f64.
Source§

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

Returns the number of years since the Modified Julian epoch as an f64.
Source§

fn years_since_j1950(&self) -> f64

Returns the number of years since J1950 as an f64.
Source§

fn years_since_j2000(&self) -> f64

Returns the number of years since J2000 as an f64.
Source§

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

Returns the number of centuries since the Modified Julian epoch as an f64.
Source§

fn centuries_since_j1950(&self) -> f64

Returns the number of centuries since J1950 as an f64.
Source§

fn centuries_since_j2000(&self) -> f64

Returns the number of centuries since J2000 as an f64.
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,

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

impl PartialEq for Date

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Date

Source§

impl Eq for Date

Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

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

Source§

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§

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

Source§

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

Source§

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.