Skip to main content

Module time

Module time 

Source
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§

LeapSeconds
Leap-second table: TAI − UTC at a given instant.
TimeScale
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.