[−][src]Crate hifitime
hifitime
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.
Features
- 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
simulation
feature) - Ephemeris Time (SPICE ET) / Barycentric Dynamical Time (IERS TDB) computations correct at least to 1e-5 seconds
TODO
- 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.
Leap second support
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,
2015-06-30 23:59:60
and 2015-07-01 00:00:00.
Does not include
- Dates only, or times only (i.e. handles only the combination of both), but the
Datetime::{at_midnight, at_noon}
help - Custom formatting of date time objects
- An initializer from machine time
Usage
Put this in your Cargo.toml
:
[dependencies]
hifitime = "1"
And add the following to your crate root:
extern crate hifitime;
Examples:
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" );
Limitations
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
Structs
ClockNoise | 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 |
Epoch | Defines an Epoch in TAI (temps atomique international) in seconds past 1900 January 01 at midnight (like the Network Time Protocol). |
Enums
Errors | Errors handles all oddities which may occur in this library. |
Constants
DAYS_PER_YEAR |
|
J1900_OFFSET |
|
J2000_OFFSET |
|
MJD_OFFSET | Modified Julian Date in seconds as defined here. MJD epoch is Modified Julian Day at 17 November 1858 at midnight. |
SECONDS_PER_DAY |
|
SECONDS_PER_HOUR |
|
SECONDS_PER_MINUTE |
|
SECONDS_PER_TROPICAL_YEAR |
|
Functions
is_gregorian_valid | Returns true if the provided Gregorian date is valid. Leap second days may have 60 seconds. |