Precise date and time handling in Rust built on top of a simple f64. The Epoch used is TAI Epoch of 01 Jan 1900 at midnight.
- Leap seconds (as announced by the IETF on a yearly basis)
- Julian dates and Modified Julian dates
- Clock drift via oscillator stability for simulation of time measuring hardware (via the
- Ephemeris Time (SPICE ET) / Barycentric Dynamical Time (IERS TDB) computations correct at least to 1e-5 seconds
- UTC representation with ISO8601 formatting (and parsing in that format)
Almost all examples are validated with external references, as detailed on a test-by-test basis.
Each time computing library may decide when the extra leap second exists as explained
in the IETF leap second reference.
To ease computation,
hifitime decides that second is the 60th of a UTC date, if such exists.
Note that this second exists at a different time than defined on
NASA HEASARC. That tool is
used for validation of Julian dates. As an example of how this is handled, check the Julian
day computations for 2015-06-30 23:59:59,
and 2015-07-01 00:00:00.
- Dates only, or times only (i.e. handles only the combination of both), but the
- Custom formatting of date time objects
- An initializer from machine time
Put this in your
[dependencies] hifitime = "1"
And add the following to your crate root:
extern crate hifitime;
use hifitime::Epoch; let mut santa = Epoch::from_gregorian_utc(2017, 12, 25, 01, 02, 14, 0); assert_eq!(santa.as_mjd_utc_days(), 58112.043217592596); assert_eq!(santa.as_jde_utc_days(), 2458112.5432175924); santa.mut_add_secs(3600.0); assert_eq!( santa, Epoch::from_gregorian_utc(2017, 12, 25, 02, 02, 14, 0), "Could not add one hour to Christmas" );
Barycentric Dynamical Time is computed using the ESA Navipedia reference. In three separate examples, the error with SPICE Ephemeris Time is the following: * -9.536743e-07 seconds for 2012-Feb-7 11:22:33 UTC * -3.814697e-06 seconds for 2002-Feb-7 midnight UTC * -4.291534e-06 seconds for 1996-Feb-7 11:22:33 UTC
ClockNoise adds true clock drift to a given Duration measurement. For example, if a vehicle is
measuring the time of flight of a signal with high precision oscillator, the engineering
specifications will include the oscillator stability. This specification bounds the preciseness
of time span calculations. On very short time spans, i.e. less than a few minutes, clock drift
is usually negligible. However, in several high fidelity systems the clock drift may lead to
a significant error (e.g. several kilometers in two-way radar ranging). This module allows high
fidelity simulation systems to test the resilience of algorithms with oscillator stability.
The constructors here are specified in parts per million: for a parts per billion specification
simply multiply the value by
Defines an Epoch in TAI (temps atomique international) in seconds past 1900 January 01 at midnight (like the Network Time Protocol).
Errors handles all oddities which may occur in this library.
Modified Julian Date in seconds as defined here. MJD epoch is Modified Julian Day at 17 November 1858 at midnight.
Returns true if the provided Gregorian date is valid. Leap second days may have 60 seconds.