Crate hifitime [−] [src]
hifitime 0.0.1
Precise date and time handling in Rust built on top of
std::time::Duration
.
The Epoch used is TAI Epoch of 01 Jan 1900 at midnight, but that should not matter in
day-to-day use of this library.
Features
- Leap seconds (as announced by the IETF on a yearly basis)
- Julian dates and Modified Julian dates
- UTC representation with ISO8601 formatting (and parsing in that format)
- Allows building custom
TimeSystem
(e.g. Julian days) - Simple to use
Offset
s to represent fixed or time-varying UTC offsets (e.g. for very high speed reference frames) - Clock drift via oscillator stability for simulation of time measuring hardware (via the
simulation
feature)
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 = "0.1.0"
And add the following to your crate root:
extern crate hifitime;
Examples:
use hifitime::datetime::{Datetime, TimeSystem}; use hifitime::instant::Duration; use hifitime::julian::ModifiedJulian; let santa = Datetime::new(2017, 12, 25, 01, 02, 14, 0).expect("Xmas failed"); assert_eq!( santa.into_instant() + Duration::new(3600, 0), Datetime::new(2017, 12, 25, 02, 02, 14, 0) .expect("Xmas failed") .into_instant(), "Could not add one hour to Christmas" ); assert_eq!(format!("{}", santa), "2017-12-25T01:02:14+00:00"); assert_eq!( ModifiedJulian::from_instant(santa.into_instant()).days, 58112.043217592596 ); assert_eq!( ModifiedJulian::from_instant(santa.into_instant()).julian_days(), 2458112.5432175924 );
Modules
datetime |
The |
durations |
The |
instant |
The |
julian |
The |
Enums
Errors |
Errors handles all oddities which may occur in this library. |
Traits
TimeSystem |
A |