Expand description
Navigation time with the time scale in the type.
Navigation uses several scales: UTC (logs, tide tables; steps with leap seconds), GPS time (receivers; continuous) and TAI (continuous, reference). They differ by whole seconds — 18 s UTC→GPS since 2017, 185 m at 20 kn — so mixing them must not compile.
An Instant carries its scale as a type parameter, like the frame of a
Direction. Instants on the same scale compare and
subtract; conversion between scales is an explicit function using the
leap-second table:
use kinavis_kernel::time::{Gps, Instant, Utc};
let utc: Instant<Utc> = Instant::from_unix_seconds(1_700_000_000);
let gps: Instant<Gps> = Instant::from_unix_seconds(1_700_000_000);
let _ = utc.duration_since(gps); // mismatched types: `Instant<Utc>` is not `Instant<Gps>`The leap-second table expires (IERS announces each leap second about six
months ahead), so it is a port, LeapSeconds, not a constant.
§Representation
Every scale counts seconds and nanoseconds since 1970-01-01T00:00:00 on
that scale. For UTC this is Unix time (a leap second has no distinct
value); GPS and TAI count continuously through leap seconds, which makes
them suitable for intervals. Instant::civil gives the calendar of the
instant’s own scale, e.g. the date a GPS receiver would display.
Structs§
- Civil
- Calendar reading.
- Gps
- GPS time: continuous, 19 s behind TAI.
- Instant
- Instant on one time scale, nanosecond resolution.
- Tai
- International Atomic Time: continuous reference scale.
- Utc
- Coordinated Universal Time, with leap seconds.
Constants§
- TAI_
MINUS_ GPS - TAI − GPS, fixed at the GPS epoch.
Traits§
- Leap
Seconds - Leap-second table: TAI − UTC at a given instant.
- Time
Scale - Time scale of an
Instant.
Functions§
- gps_
to_ tai - GPS → TAI: fixed 19 s.
- gps_
to_ utc - GPS → UTC.
- tai_
to_ gps - TAI → GPS: fixed 19 s.
- tai_
to_ utc - TAI → UTC.
- utc_
to_ gps - UTC → GPS.
- utc_
to_ tai - UTC → TAI.