pub struct Epoch(_);
Expand description

Defines an Epoch in TAI (temps atomique international) in seconds past 1900 January 01 at midnight (like the Network Time Protocol).

Refer to the appropriate functions for initializing this Epoch from different time systems or representations.

Implementations

Get the accumulated number of leap seconds up to this Epoch.

Creates a new Epoch from a Duration as the time difference between this epoch and TAI reference epoch.

Creates a new Epoch from its centuries and nanosecond since the TAI reference epoch.

Initialize an Epoch from the provided TAI seconds since 1900 January 01 at midnight

Initialize an Epoch from the provided TAI days since 1900 January 01 at midnight

Initialize an Epoch from the provided UTC seconds since 1900 January 01 at midnight

Initialize an Epoch from the provided UTC days since 1900 January 01 at midnight

Initialize an Epoch from the provided TT seconds (approximated to 32.184s delta from TAI)

Initialized from the Ephemeris Time seconds

Initialize from Dynamic Barycentric Time (TDB) (same as SPICE ephemeris time) whose epoch is 2000 JAN 01 noon TAI

Initialize from the JDE dayes

Initialize from Dynamic Barycentric Time (TDB) (same as SPICE ephemeris time) in JD days

Initialize an Epoch from the number of seconds since the GPS Time Epoch, defined as UTC midnight of January 5th to 6th 1980 (cf. https://gssc.esa.int/navipedia/index.php/Time_References_in_GNSS#GPS_Time_.28GPST.29).

Initialize an Epoch from the number of days since the GPS Time Epoch, defined as UTC midnight of January 5th to 6th 1980 (cf. https://gssc.esa.int/navipedia/index.php/Time_References_in_GNSS#GPS_Time_.28GPST.29).

Initialize an Epoch from the number of nanoseconds since the GPS Time Epoch, defined as UTC midnight of January 5th to 6th 1980 (cf. https://gssc.esa.int/navipedia/index.php/Time_References_in_GNSS#GPS_Time_.28GPST.29). This may be useful for time keeping devices that use GPS as a time source.

Initialize an Epoch from the provided UNIX second timestamp since UTC midnight 1970 January 01.

Initialize an Epoch from the provided UNIX milisecond timestamp since UTC midnight 1970 January 01.

Attempts to build an Epoch from the provided Gregorian date and time in TAI.

Attempts to build an Epoch from the provided Gregorian date and time in the provided time system.

Builds an Epoch from the provided Gregorian date and time in TAI. If invalid date is provided, this function will panic. Use maybe_from_gregorian_tai if unsure.

Initialize from the Gregoerian date at midnight in TAI.

Initialize from the Gregorian date at noon in TAI

Initialize from the Gregorian date and time (without the nanoseconds) in TAI

Attempts to build an Epoch from the provided Gregorian date and time in UTC.

Builds an Epoch from the provided Gregorian date and time in TAI. If invalid date is provided, this function will panic. Use maybe_from_gregorian_tai if unsure.

Initialize from Gregorian date in UTC at midnight

Initialize from Gregorian date in UTC at noon

Initialize from the Gregorian date and time (without the nanoseconds) in UTC

Returns the number of TAI seconds since J1900

Returns this time in a Duration past J1900 counted in TAI

Returns the epoch as a floating point value in the provided unit

Returns the TAI parts of this duration

Returns the number of days since J1900 in TAI

Returns the number of UTC seconds since the TAI epoch

Returns this time in a Duration past J1900 counted in UTC

Returns the number of UTC seconds since the TAI epoch

Returns the number of UTC days since the TAI epoch

as_mjd_days creates an Epoch from the provided Modified Julian Date in days as explained here. MJD epoch is Modified Julian Day at 17 November 1858 at midnight.

Returns the Modified Julian Date in seconds TAI.

Returns this epoch as a duration in the requested units in MJD TAI

Returns the Modified Julian Date in days UTC.

Returns the Modified Julian Date in the provided unit in UTC.

Returns the Modified Julian Date in seconds UTC.

Returns the Julian days from epoch 01 Jan -4713, 12:00 (noon) as explained in “Fundamentals of astrodynamics and applications”, Vallado et al. 4th edition, page 182, and on Wikipedia.

Returns the Julian seconds in TAI.

Returns the Julian days in UTC.

Returns the Julian seconds in UTC.

Returns seconds past TAI epoch in Terrestrial Time (TT) (previously called Terrestrial Dynamical Time (TDT))

Returns days past TAI epoch in Terrestrial Time (TT) (previously called Terrestrial Dynamical Time (TDT))

Returns the centuries pased J2000 TT

Returns the duration past J2000 TT

Returns days past Julian epoch in Terrestrial Time (TT) (previously called Terrestrial Dynamical Time (TDT))

Returns days past Modified Julian epoch in Terrestrial Time (TT) (previously called Terrestrial Dynamical Time (TDT))

Returns seconds past GPS Time Epoch, defined as UTC midnight of January 5th to 6th 1980 (cf. https://gssc.esa.int/navipedia/index.php/Time_References_in_GNSS#GPS_Time_.28GPST.29).

Returns nanoseconds past GPS Time Epoch, defined as UTC midnight of January 5th to 6th 1980 (cf. https://gssc.esa.int/navipedia/index.php/Time_References_in_GNSS#GPS_Time_.28GPST.29). NOTE: This function will return an error if the centuries past GPST time are not zero.

Returns days past GPS Time Epoch, defined as UTC midnight of January 5th to 6th 1980 (cf. https://gssc.esa.int/navipedia/index.php/Time_References_in_GNSS#GPS_Time_.28GPST.29).

Returns the duration since the UNIX epoch in the provided unit.

Returns the number seconds since the UNIX epoch defined 01 Jan 1970 midnight UTC.

Returns the number milliseconds since the UNIX epoch defined 01 Jan 1970 midnight UTC.

Returns the number days since the UNIX epoch defined 01 Jan 1970 midnight UTC.

Returns the Ephemeris Time seconds past epoch

Returns the Dynamics Barycentric Time (TDB) as a high precision Duration

Returns the Dynamic Barycentric Time (TDB) (higher fidelity SPICE ephemeris time) whose epoch is 2000 JAN 01 noon TAI (cf. https://gssc.esa.int/navipedia/index.php/Transformations_between_Time_Systems#TDT_-_TDB.2C_TCB)

Returns the Ephemeris Time JDE past epoch

Returns the Dynamic Barycentric Time (TDB) (higher fidelity SPICE ephemeris time) whose epoch is 2000 JAN 01 noon TAI (cf. https://gssc.esa.int/navipedia/index.php/Transformations_between_Time_Systems#TDT_-_TDB.2C_TCB)

Returns the duration since Dynamic Barycentric Time (TDB) J2000 (used for Archinal et al. rotations)

Returns the number of days since Dynamic Barycentric Time (TDB) J2000 (used for Archinal et al. rotations)

Returns the number of centuries since Dynamic Barycentric Time (TDB) J2000 (used for Archinal et al. rotations)

Returns the duration since Ephemeris Time (ET) J2000 (used for Archinal et al. rotations)

Returns the number of days since Ephemeris Time (ET) J2000 (used for Archinal et al. rotations)

Returns the number of centuries since Ephemeris Time (ET) J2000 (used for Archinal et al. rotations)

Converts the Epoch to the Gregorian UTC equivalent as (year, month, day, hour, minute, second). WARNING: Nanoseconds are lost in this conversion!

Example
use hifitime::Epoch;

let dt = Epoch::from_tai_parts(1, 537582752000000000);

// With the std feature, you may use FromStr as such
// let dt_str = "2017-01-14T00:31:55 UTC";
// let dt = Epoch::from_gregorian_str(dt_str).unwrap()

let (y, m, d, h, min, s, _) = dt.as_gregorian_utc();
assert_eq!(y, 2017);
assert_eq!(m, 1);
assert_eq!(d, 14);
assert_eq!(h, 0);
assert_eq!(min, 31);
assert_eq!(s, 55);
#[cfg(feature = "std")]
assert_eq!("2017-01-14T00:31:55 UTC", dt.as_gregorian_utc_str().to_owned());

Converts the Epoch to the Gregorian TAI equivalent as (year, month, day, hour, minute, second). WARNING: Nanoseconds are lost in this conversion!

Example
use hifitime::Epoch;
let dt = Epoch::from_gregorian_tai_at_midnight(1972, 1, 1);
let (y, m, d, h, min, s, _) = dt.as_gregorian_tai();
assert_eq!(y, 1972);
assert_eq!(m, 1);
assert_eq!(d, 1);
assert_eq!(h, 0);
assert_eq!(min, 0);
assert_eq!(s, 0);

Floors this epoch to the closest provided duration

Example
use hifitime::{Epoch, TimeUnits};

let e = Epoch::from_gregorian_tai_hms(2022, 5, 20, 17, 57, 43);
assert_eq!(
    e.floor(1.hours()),
    Epoch::from_gregorian_tai_hms(2022, 5, 20, 17, 0, 0)
);

Ceils this epoch to the closest provided duration

Example
use hifitime::{Epoch, TimeUnits};

let e = Epoch::from_gregorian_tai_hms(2022, 5, 20, 17, 57, 43);
assert_eq!(
    e.ceil(1.hours()),
    Epoch::from_gregorian_tai_hms(2022, 5, 20, 18, 0, 0)
);

Rounds this epoch to the closest provided duration

Example
use hifitime::{Epoch, TimeUnits};

let e = Epoch::from_gregorian_tai_hms(2022, 5, 20, 17, 57, 43);
assert_eq!(
    e.round(1.hours()),
    Epoch::from_gregorian_tai_hms(2022, 5, 20, 18, 0, 0)
);

Converts an ISO8601 Datetime representation without timezone offset to an Epoch. If no time system is specified, than UTC is assumed. The T which separates the date from the time can be replaced with a single whitespace character (\W). The offset is also optional, cf. the examples below.

Example
use hifitime::Epoch;
let dt = Epoch::from_gregorian_utc(2017, 1, 14, 0, 31, 55, 0);
assert_eq!(
    dt,
    Epoch::from_gregorian_str("2017-01-14T00:31:55 UTC").unwrap()
);
assert_eq!(
    dt,
    Epoch::from_gregorian_str("2017-01-14T00:31:55.0000 UTC").unwrap()
);
assert_eq!(
    dt,
    Epoch::from_gregorian_str("2017-01-14T00:31:55").unwrap()
);
assert_eq!(
    dt,
    Epoch::from_gregorian_str("2017-01-14 00:31:55").unwrap()
);
// Regression test for #90
assert_eq!(
    Epoch::from_gregorian_utc(2017, 1, 14, 0, 31, 55, 811000000),
    Epoch::from_gregorian_str("2017-01-14 00:31:55.811 UTC").unwrap()
);
assert_eq!(
    Epoch::from_gregorian_utc(2017, 1, 14, 0, 31, 55, 811200000),
    Epoch::from_gregorian_str("2017-01-14 00:31:55.8112 UTC").unwrap()
);

Converts the Epoch to UTC Gregorian in the ISO8601 format.

Converts the Epoch to TAI Gregorian in the ISO8601 format with “ TAI“ appended to the string

Converts the Epoch to Gregorian in the provided time system and in the ISO8601 format with the time system appended to the string

Initializes a new Epoch from now. WARNING: This assumes that the system time returns the time in UTC (which is the case on Linux) Uses std::time::SystemTime::now under the hood

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

WARNING: For speed, there is a possibility to add seconds directly to an Epoch. Using this is discouraged and should only be used if you have facing bottlenecks with the units.

The resulting type after applying the + operator.

Performs the += operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

The default format of an epoch is in UTC

Attempts to convert a string to an Epoch.

Format identifiers:

  • JD: Julian days
  • MJD: Modified Julian days
  • SEC: Seconds past a given epoch (e.g. SEC 17.2 TAI is 17.2 seconds past TAI Epoch)
Example
use hifitime::Epoch;
use std::str::FromStr;

assert!(Epoch::from_str("JD 2452312.500372511 TDB").is_ok());
assert!(Epoch::from_str("JD 2452312.500372511 ET").is_ok());
assert!(Epoch::from_str("JD 2452312.500372511 TAI").is_ok());
assert!(Epoch::from_str("MJD 51544.5 TAI").is_ok());
assert!(Epoch::from_str("SEC 0.5 TAI").is_ok());
assert!(Epoch::from_str("SEC 66312032.18493909 TDB").is_ok());

The associated error which can be returned from parsing.

Prints the Epoch in TDB

Prints the Epoch in TAI

Prints the Epoch in GPS

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Prints the Epoch in UNIX

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Performs the -= operation. Read more

Prints the Epoch in ET

Prints the Epoch in TT

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Method to serialize generic items, slices, and slices of Vecs. Adds square brackets around Vecs (prettier lists). Implementation code is in printing.rs. Read more

Method to serialize generic items, slices, and slices of Vecs. Implementation code is in printing.rs. Read more

Printable in red

Printable in green

Printable in blue

Printable in yellow

Printable in magenta

Printable in cyan

Method to write vector(s) to file f (space separated, without brackets). Passes up io errors Read more

Method to print vector(s) to stdout (space separated,without brackets).

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.