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>
impl<Scale: ?Sized> TimePoint<Scale>
Sourcepub const fn from_time_since_epoch(time_since_epoch: Duration) -> Self
pub const fn from_time_since_epoch(time_since_epoch: Duration) -> Self
Constructs a new TimePoint from a known time since epoch.
Sourcepub const fn time_since_epoch(&self) -> Duration
pub const fn time_since_epoch(&self) -> Duration
Returns the time elapsed since the epoch of the time scale associated with this instant.
Sourcepub const fn count(&self) -> i128
pub const fn count(&self) -> i128
Returns the raw underlying representation of this time point.
Sourcepub fn round<Target>(self) -> TimePoint<Scale>where
Target: UnitRatio,
pub fn round<Target>(self) -> TimePoint<Scale>where
Target: UnitRatio,
Converts towards a different time unit, rounding towards the nearest whole unit.
Sourcepub fn ceil<Target>(self) -> TimePoint<Scale>where
Target: UnitRatio,
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.
Sourcepub fn floor<Target>(self) -> TimePoint<Scale>where
Target: UnitRatio,
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.
Sourcepub 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,
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.
Sourcepub 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,
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.
Sourcepub 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,
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,
impl<Scale> TimePoint<Scale>where
Scale: UniformDateTimeScale + ?Sized,
Sourcepub fn from_modified_julian_date(mjd: ModifiedJulianDate) -> Self
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,
impl<Scale> TimePoint<Scale>where
Scale: AbsoluteTimeScale + ?Sized,
Sourcepub fn into_modified_julian_date(&self) -> ModifiedJulianDate
pub fn into_modified_julian_date(&self) -> ModifiedJulianDate
Converts this time point into the equivalent Julian day representation.
Source§impl<Scale> TimePoint<Scale>
impl<Scale> TimePoint<Scale>
Sourcepub 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>>
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.
Sourcepub 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>>
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.
Sourcepub 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>>
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,
impl<Scale: ?Sized> TimePoint<Scale>where
Self: IntoDateTime,
Sourcepub fn into_historic_datetime(self) -> (HistoricDate, u8, u8, u8)
pub fn into_historic_datetime(self) -> (HistoricDate, u8, u8, u8)
Maps a TimePoint towards the corresponding historic date and time-of-day.
Sourcepub fn into_gregorian_datetime(self) -> (GregorianDate, u8, u8, u8)
pub fn into_gregorian_datetime(self) -> (GregorianDate, u8, u8, u8)
Maps a TimePoint towards the corresponding proleptic Gregorian date and time-of-day.
Sourcepub fn into_julian_datetime(self) -> (JulianDate, u8, u8, u8)
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,
impl<Scale: ?Sized> TimePoint<Scale>where
Self: IntoFineDateTime,
pub fn into_fine_historic_datetime(self) -> (HistoricDate, u8, u8, u8, Duration)
pub fn into_fine_gregorian_datetime( self, ) -> (GregorianDate, u8, u8, u8, Duration)
pub fn into_fine_julian_datetime(self) -> (JulianDate, u8, u8, u8, Duration)
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_bdt(time_point: BeiDouTime) -> Selfwhere
Self: FromTimeScale<Bdt>,
pub fn into_bdt(self) -> BeiDouTimewhere
Self: IntoTimeScale<Bdt>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_glonasst(time_point: GlonassTime) -> Selfwhere
Self: FromTimeScale<Glonasst>,
pub fn into_glonasst(self) -> GlonassTimewhere
Self: IntoTimeScale<Glonasst>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_gpst(time_point: GpsTime) -> Selfwhere
Self: FromTimeScale<Gpst>,
pub fn into_gpst(self) -> GpsTimewhere
Self: IntoTimeScale<Gpst>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_gst(time_point: GalileoTime) -> Selfwhere
Self: FromTimeScale<Gst>,
pub fn into_gst(self) -> GalileoTimewhere
Self: IntoTimeScale<Gst>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_qzsst(time_point: QzssTime) -> Selfwhere
Self: FromTimeScale<Qzsst>,
pub fn into_qzsst(self) -> QzssTimewhere
Self: IntoTimeScale<Qzsst>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_tai(time_point: TaiTime) -> Selfwhere
Self: FromTimeScale<Tai>,
pub fn into_tai(self) -> TaiTimewhere
Self: IntoTimeScale<Tai>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_tcg(time_point: TcgTime) -> Selfwhere
Self: FromTimeScale<Tcg>,
pub fn into_tcg(self) -> TcgTimewhere
Self: IntoTimeScale<Tcg>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_tcb(time_point: TcbTime) -> Selfwhere
Self: FromTimeScale<Tcb>,
pub fn into_tcb(self) -> TcbTimewhere
Self: IntoTimeScale<Tcb>,
Source§impl<Scale: ?Sized> TimePoint<Scale>
impl<Scale: ?Sized> TimePoint<Scale>
pub fn from_tdb(time_point: TdbTime) -> Selfwhere
Self: FromTimeScale<Tdb>,
pub fn into_tdb(self) -> TdbTimewhere
Self: IntoTimeScale<Tdb>,
Source§impl TimePoint<Tt>
impl TimePoint<Tt>
Sourcepub fn approximate_tdb(self) -> TdbTime
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”.
Trait Implementations§
Source§impl<Scale> AddAssign<Duration> for TimePoint<Scale>where
Scale: ?Sized,
impl<Scale> AddAssign<Duration> for TimePoint<Scale>where
Scale: ?Sized,
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moreSource§impl<'de, Scale> Deserialize<'de> for TimePoint<Scale>
Available on crate feature serde only.
impl<'de, Scale> Deserialize<'de> for TimePoint<Scale>
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<Scale> FromDateTime for TimePoint<Scale>where
Scale: ?Sized + UniformDateTimeScale,
impl<Scale> FromDateTime for TimePoint<Scale>where
Scale: ?Sized + UniformDateTimeScale,
Source§type Error = InvalidTimeOfDay
type Error = InvalidTimeOfDay
Source§impl<Scale> FromFineDateTime for TimePoint<Scale>
impl<Scale> FromFineDateTime for TimePoint<Scale>
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>
fn from_fine_datetime( date: Date, hour: u8, minute: u8, second: u8, subseconds: Duration, ) -> Result<Self, Self::Error>
Source§impl<Scale> FromStr for TimePoint<Scale>where
Self: FromFineDateTime,
Scale: TimeScale,
impl<Scale> FromStr for TimePoint<Scale>where
Self: FromFineDateTime,
Scale: TimeScale,
Source§fn from_str(string: &str) -> Result<Self, Self::Err>
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>
type Err = TimePointParsingError<<TimePoint<Scale> as FromFineDateTime>::Error>
Source§impl<ScaleFrom, ScaleInto> FromTimeScale<ScaleFrom> for TimePoint<ScaleInto>where
ScaleFrom: TerrestrialTime,
ScaleInto: TerrestrialTime,
impl<ScaleFrom, ScaleInto> FromTimeScale<ScaleFrom> for TimePoint<ScaleInto>where
ScaleFrom: TerrestrialTime,
ScaleInto: TerrestrialTime,
Source§fn from_time_scale(time_point: TimePoint<ScaleFrom>) -> Self
fn from_time_scale(time_point: TimePoint<ScaleFrom>) -> Self
Source§impl<Scale> IntoDateTime for TimePoint<Scale>where
Scale: ?Sized + UniformDateTimeScale,
impl<Scale> IntoDateTime for TimePoint<Scale>where
Scale: ?Sized + UniformDateTimeScale,
Source§impl<Scale> IntoFineDateTime for TimePoint<Scale>where
Scale: ?Sized,
Self: IntoDateTime,
impl<Scale> IntoFineDateTime for TimePoint<Scale>where
Scale: ?Sized,
Self: IntoDateTime,
Source§fn into_fine_datetime(self) -> (Date, u8, u8, u8, Duration)
fn into_fine_datetime(self) -> (Date, u8, u8, u8, Duration)
Source§impl<S1, S2> IntoTimeScale<S1> for TimePoint<S2>where
TimePoint<S1>: FromTimeScale<S2>,
impl<S1, S2> IntoTimeScale<S1> for TimePoint<S2>where
TimePoint<S1>: FromTimeScale<S2>,
Source§fn into_time_scale(self) -> TimePoint<S1>
fn into_time_scale(self) -> TimePoint<S1>
Source§impl<Scale: ?Sized> Ord for TimePoint<Scale>
impl<Scale: ?Sized> Ord for TimePoint<Scale>
Source§impl<Scale: ?Sized> PartialOrd for TimePoint<Scale>
impl<Scale: ?Sized> PartialOrd for TimePoint<Scale>
Source§impl<Scale> SubAssign<Duration> for TimePoint<Scale>where
Scale: ?Sized,
impl<Scale> SubAssign<Duration> for TimePoint<Scale>where
Scale: ?Sized,
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read more