TimePoint

Struct TimePoint 

Source
pub struct TimePoint<Scale: ?Sized> { /* private fields */ }
Expand description

A TimePoint identifies a specific instant in time. It is templated on a Representation and Period, which the define the characteristics of the Duration type used to represent the time elapsed since the epoch of the underlying time scale Scale.

Implementations§

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub const fn from_time_since_epoch(time_since_epoch: Duration) -> Self

Constructs a new TimePoint from a known time since epoch.

Source

pub const fn time_since_epoch(&self) -> Duration

Returns the time elapsed since the epoch of the time scale associated with this instant.

Source

pub const fn count(&self) -> i128

Returns the raw underlying representation of this time point.

Source

pub fn round<Target>(self) -> TimePoint<Scale>
where Target: UnitRatio,

Converts towards a different time unit, rounding towards the nearest whole unit.

Source

pub fn ceil<Target>(self) -> TimePoint<Scale>
where Target: UnitRatio,

Converts towards a different time unit, rounding towards positive infinity if the unit is not entirely commensurate with the present unit.

Source

pub fn floor<Target>(self) -> TimePoint<Scale>
where Target: UnitRatio,

Converts towards a different time unit, rounding towards negative infinity if the unit is not entirely commensurate with the present unit.

Source

pub fn from_historic_datetime( year: i32, month: Month, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<Self, InvalidHistoricDateTime<<Self as FromDateTime>::Error>>
where Self: FromDateTime,

Constructs a TimePoint in the given time scale, based on a historic date-time.

Source

pub fn from_gregorian_datetime( year: i32, month: Month, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<Self, InvalidGregorianDateTime<<Self as FromDateTime>::Error>>
where Self: FromDateTime,

Constructs a TimePoint in the given time scale, based on a Gregorian date-time.

Source

pub fn from_julian_datetime( year: i32, month: Month, day: u8, hour: u8, minute: u8, second: u8, ) -> Result<Self, InvalidJulianDateTime<<Self as FromDateTime>::Error>>
where Self: FromDateTime,

Constructs a TimePoint in the given time scale, based on a Julian date-time.

Source§

impl<Scale> TimePoint<Scale>
where Scale: UniformDateTimeScale + ?Sized,

Source

pub fn from_modified_julian_date(mjd: ModifiedJulianDate) -> Self

Constructs a time point from a modified Julian date, expressed in the resulting time scale itself. The modified Julian date uses 17 November, 1858 (historic calendar) as epoch, or 2400000.5 days less than the Julian day.

Conversions from modified Julian days into TimePoints are supported only for uniform date time scales. For non-uniform time scales, leap second days result in ambiguous and difficult to implement interpretations of the fractional part of a day. Based on the “Resolution B1 on the use of Julian Dates” of the IAU, it is also not recommended to use such Julian date expressions: hence, we do not support it.

Source§

impl<Scale> TimePoint<Scale>
where Scale: AbsoluteTimeScale + ?Sized,

Source

pub fn into_modified_julian_date(&self) -> ModifiedJulianDate

Converts this time point into the equivalent Julian day representation.

Source§

impl<Scale> TimePoint<Scale>
where Self: FromFineDateTime, TimePoint<Scale>: FromDateTime, Scale: ?Sized,

Source

pub fn from_fine_historic_datetime( year: i32, month: Month, day: u8, hour: u8, minute: u8, second: u8, subseconds: Duration, ) -> Result<Self, InvalidHistoricDateTime<<Self as FromFineDateTime>::Error>>

Constructs a TimePoint in the given time scale, based on a subsecond-accuracy historic date-time.

Source

pub fn from_fine_gregorian_datetime( year: i32, month: Month, day: u8, hour: u8, minute: u8, second: u8, subseconds: Duration, ) -> Result<Self, InvalidGregorianDateTime<<Self as FromFineDateTime>::Error>>

Constructs a TimePoint in the given time scale, based on a subsecond-accuracy Gregorian date-time.

Source

pub fn from_fine_julian_datetime( year: i32, month: Month, day: u8, hour: u8, minute: u8, second: u8, subseconds: Duration, ) -> Result<Self, InvalidJulianDateTime<<Self as FromFineDateTime>::Error>>

Constructs a TimePoint in the given time scale, based on a subsecond-accuracy Julian date-time.

Source§

impl<Scale: ?Sized> TimePoint<Scale>
where Self: IntoDateTime,

Source

pub fn into_historic_datetime(self) -> (HistoricDate, u8, u8, u8)

Maps a TimePoint towards the corresponding historic date and time-of-day.

Source

pub fn into_gregorian_datetime(self) -> (GregorianDate, u8, u8, u8)

Maps a TimePoint towards the corresponding proleptic Gregorian date and time-of-day.

Source

pub fn into_julian_datetime(self) -> (JulianDate, u8, u8, u8)

Maps a TimePoint towards the corresponding Julian date and time-of-day.

Source§

impl<Scale: ?Sized> TimePoint<Scale>
where Self: IntoFineDateTime,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_bdt(time_point: BeiDouTime) -> Self
where Self: FromTimeScale<Bdt>,

Source

pub fn into_bdt(self) -> BeiDouTime
where Self: IntoTimeScale<Bdt>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_glonasst(time_point: GlonassTime) -> Self
where Self: FromTimeScale<Glonasst>,

Source

pub fn into_glonasst(self) -> GlonassTime
where Self: IntoTimeScale<Glonasst>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_gpst(time_point: GpsTime) -> Self
where Self: FromTimeScale<Gpst>,

Source

pub fn into_gpst(self) -> GpsTime
where Self: IntoTimeScale<Gpst>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_gst(time_point: GalileoTime) -> Self
where Self: FromTimeScale<Gst>,

Source

pub fn into_gst(self) -> GalileoTime
where Self: IntoTimeScale<Gst>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_qzsst(time_point: QzssTime) -> Self
where Self: FromTimeScale<Qzsst>,

Source

pub fn into_qzsst(self) -> QzssTime
where Self: IntoTimeScale<Qzsst>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_tai(time_point: TaiTime) -> Self
where Self: FromTimeScale<Tai>,

Source

pub fn into_tai(self) -> TaiTime
where Self: IntoTimeScale<Tai>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_tcg(time_point: TcgTime) -> Self
where Self: FromTimeScale<Tcg>,

Source

pub fn into_tcg(self) -> TcgTime
where Self: IntoTimeScale<Tcg>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_tcb(time_point: TcbTime) -> Self
where Self: FromTimeScale<Tcb>,

Source

pub fn into_tcb(self) -> TcbTime
where Self: IntoTimeScale<Tcb>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_tdb(time_point: TdbTime) -> Self
where Self: FromTimeScale<Tdb>,

Source

pub fn into_tdb(self) -> TdbTime
where Self: IntoTimeScale<Tdb>,

Source§

impl TimePoint<Tt>

Source

pub fn approximate_tdb(self) -> TdbTime

Approximates Barycentric Dynamical Time (BDT) from TT using a simplified expression following the IAU SOFA estimate TDB = TT + 0.001657 * sin(g) where g is an estimate of the Earth’s mean anomaly. The resulting estimate is accurate to 50 microseconds from 1980 to 2100.

See “SOFA Time Scale and Calendar Tools”, 2023 May 31, version for the C programming language. Section 4.3.4 “TDB minus TT”.

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_tt(time_point: TtTime) -> Self
where Self: FromTimeScale<Tt>,

Source

pub fn into_tt(self) -> TtTime
where Self: IntoTimeScale<Tt>,

Source§

impl<Scale: ?Sized> TimePoint<Scale>

Source

pub fn from_utc(time_point: UtcTime) -> Self
where Self: FromTimeScale<Utc>,

Source

pub fn into_utc(self) -> UtcTime
where Self: IntoTimeScale<Utc>,

Trait Implementations§

Source§

impl<Scale> Add<Duration> for TimePoint<Scale>
where Scale: ?Sized,

Source§

type Output = TimePoint<Scale>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
Source§

impl<Scale> AddAssign<Duration> for TimePoint<Scale>
where Scale: ?Sized,

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl<Scale> Bounded for TimePoint<Scale>
where Scale: ?Sized,

Source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
Source§

fn max_value() -> Self

Returns the largest finite number this type can represent
Source§

impl<Scale: ?Sized> Clone for TimePoint<Scale>

Source§

fn clone(&self) -> Self

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<Scale: ?Sized> Debug for TimePoint<Scale>

Source§

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

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

impl<'de, Scale> Deserialize<'de> for TimePoint<Scale>
where Self: FromStr, <Self as FromStr>::Err: Display, Scale: ?Sized,

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Scale> Display for TimePoint<Scale>
where Scale: ?Sized + TimeScale, Duration: Zero, Self: IntoFineDateTime,

Source§

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

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

impl<Scale> FromDateTime for TimePoint<Scale>
where Scale: ?Sized + UniformDateTimeScale,

Source§

type Error = InvalidTimeOfDay

This error may be returned whenever some input date-time is not valid. This may be the case when the time-of-day is not valid, but also when some date-time does not occur in a chosen time scale, for example due to leap seconds deletions or daylight saving time switches.
Source§

fn from_datetime( date: Date, hour: u8, minute: u8, second: u8, ) -> Result<Self, Self::Error>

Maps a given combination of date and time-of-day to an instant on this time scale. May return an error if the input does not represent a valid combination of date and time-of-day.
Source§

impl<Scale> FromFineDateTime for TimePoint<Scale>
where Scale: ?Sized, TimePoint<Scale>: FromDateTime,

Source§

type Error = <TimePoint<Scale> as FromDateTime>::Error

Source§

fn from_fine_datetime( date: Date, hour: u8, minute: u8, second: u8, subseconds: Duration, ) -> Result<Self, Self::Error>

Maps a given combination of date and fine time-of-day to an instant on this time scale. May return an error if the input does not represent a valid combination of date and time-of-day.
Source§

impl<Scale> FromStr for TimePoint<Scale>
where Self: FromFineDateTime, Scale: TimeScale,

Source§

fn from_str(string: &str) -> Result<Self, Self::Err>

Parses a TimePoint based on some ISO 8610 date and time of day string. Note that time shifts are explicitly not supported: those are already included in the choice of Scale for a type. Additionally, we only support the extended calendar date and time of day formats (see section 5.4.2.1 of ISO 8610). Finally, because the extended format is used (which explicitly delimits time point components), any number of digits is allowed in the year component, such that its range can be extended beyond the 0000..=9999 allowed by ISO 8601.

Source§

type Err = TimePointParsingError<<TimePoint<Scale> as FromFineDateTime>::Error>

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

impl<ScaleFrom, ScaleInto> FromTimeScale<ScaleFrom> for TimePoint<ScaleInto>
where ScaleFrom: TerrestrialTime, ScaleInto: TerrestrialTime,

Source§

fn from_time_scale(time_point: TimePoint<ScaleFrom>) -> Self

Constructs a time point from an instant expressed in another scale.
Source§

impl<Scale: ?Sized> Hash for TimePoint<Scale>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Scale> IntoDateTime for TimePoint<Scale>
where Scale: ?Sized + UniformDateTimeScale,

Source§

fn into_datetime(self) -> (Date, u8, u8, u8)

Maps a time point back to the date and time-of-day that it represents. Returns a tuple of date, hour, minute, and second. This function shall not fail, unless overflow occurs in the underlying integer arithmetic.
Source§

impl<Scale> IntoFineDateTime for TimePoint<Scale>
where Scale: ?Sized, Self: IntoDateTime,

Source§

fn into_fine_datetime(self) -> (Date, u8, u8, u8, Duration)

Convenience function that maps from a “fine” (subsecond-accuracy) time point to a date-time according to this time scale. Returns a tuple of date, hour, minute, second, and subsecond. Shall not fail, unless overflow occurs in the underlying integer arithmetic.
Source§

impl<S1, S2> IntoTimeScale<S1> for TimePoint<S2>
where TimePoint<S1>: FromTimeScale<S2>,

Source§

fn into_time_scale(self) -> TimePoint<S1>

Constructs a time point from an instant expressed in another scale.
Source§

impl<Scale: ?Sized> Ord for TimePoint<Scale>

Source§

fn cmp(&self, other: &Self) -> 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<Scale: ?Sized> PartialEq for TimePoint<Scale>

Source§

fn eq(&self, other: &Self) -> 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<Scale: ?Sized> PartialOrd for TimePoint<Scale>

Source§

fn partial_cmp(&self, other: &Self) -> 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<Scale> Serialize for TimePoint<Scale>
where Self: ToString, Scale: ?Sized,

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<Scale> Sub<Duration> for TimePoint<Scale>
where Scale: ?Sized,

Source§

type Output = TimePoint<Scale>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Duration) -> Self::Output

Performs the - operation. Read more
Source§

impl<Scale> Sub for TimePoint<Scale>
where Scale: ?Sized,

Source§

type Output = Duration

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<Scale> SubAssign<Duration> for TimePoint<Scale>
where Scale: ?Sized,

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl<Scale: ?Sized> Copy for TimePoint<Scale>

Source§

impl<Scale: ?Sized> Eq for TimePoint<Scale>

Auto Trait Implementations§

§

impl<Scale> Freeze for TimePoint<Scale>
where Scale: ?Sized,

§

impl<Scale> RefUnwindSafe for TimePoint<Scale>
where Scale: RefUnwindSafe + ?Sized,

§

impl<Scale> Send for TimePoint<Scale>
where Scale: Send + ?Sized,

§

impl<Scale> Sync for TimePoint<Scale>
where Scale: Sync + ?Sized,

§

impl<Scale> Unpin for TimePoint<Scale>
where Scale: Unpin + ?Sized,

§

impl<Scale> UnwindSafe for TimePoint<Scale>
where Scale: UnwindSafe + ?Sized,

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<TimePoint> FromDateTime for TimePoint
where TimePoint: FromLeapSecondDateTime,

Source§

type Error = <TimePoint as FromLeapSecondDateTime>::Error

This error may be returned whenever some input date-time is not valid. This may be the case when the time-of-day is not valid, but also when some date-time does not occur in a chosen time scale, for example due to leap seconds deletions or daylight saving time switches.
Source§

fn from_datetime( date: Date, hour: u8, minute: u8, second: u8, ) -> Result<TimePoint, <TimePoint as FromDateTime>::Error>

Maps a given combination of date and time-of-day to an instant on this time scale. May return an error if the input does not represent a valid combination of date and time-of-day.
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<TimePoint> IntoDateTime for TimePoint
where TimePoint: IntoLeapSecondDateTime,

Source§

fn into_datetime(self) -> (Date, u8, u8, u8)

Maps a time point back to the date and time-of-day that it represents. Returns a tuple of date, hour, minute, and second. This function shall not fail, unless overflow occurs in the underlying integer arithmetic.
Source§

impl<T> LowerBounded for T
where T: Bounded,

Source§

fn min_value() -> T

Returns the smallest finite number this type can represent
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.
Source§

impl<T> UpperBounded for T
where T: Bounded,

Source§

fn max_value() -> T

Returns the largest finite number this type can represent
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,