@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
53 lines • 2.63 kB
TypeScript
import { GnssSystem } from "../types/gnss.js";
import { UtcReading } from "./utcReading.js";
import { TimeScaleLabel } from "./timeScaleString.js";
/** How one satellite system's time scale relates to TAI, and where its labels start. */
export interface GnssTimeScale {
/** TAI minus the scale, in seconds; null for GLO, which is UTC's own wall clock. */
readonly taiMinusScale: bigint | null;
/** First defined label, label nanoseconds. */
readonly epochLabel: bigint;
}
/**
* The satellite time scales by RINEX 4.02 §5.2.8 time-system identifier. Each `epochLabel` is
* `Temporal.PlainDateTime.from(<label>).toZonedDateTime("UTC").epochNanoseconds` of the label in
* its comment; gnssTimeScales.test.ts asserts each one. The offsets are nominal: the broadcast
* corrections (C0, A0/A1, GGTO), tens of nanoseconds, are not inputs.
*/
export declare const GNSS_TIME_SCALES: Readonly<Record<GnssSystem, GnssTimeScale>>;
/**
* Whether a value is one of the six RINEX 4.02 §5.2.8 time-system identifiers GMT reads.
*
* @param value candidate system
* @returns true for `GPS`, `GAL`, `BDT`, `QZS`, `GLO` or `IRN`
*/
export declare function isGnssSystem(value: unknown): value is GnssSystem;
/**
* A UTC reading as a label on a satellite system's scale.
*
* - TAI-based scales: TAI from the leap-second table, minus the scale's fixed offset. A listed
* inserted second maps to its own label; the result is never second 60.
* - `GLO`: the reading itself, second 60 included, once the table has checked it.
* - `null` when the reading has no TAI instant (before 1972, or a second 60 on a day with no
* insertion), or when the label falls before the scale's epoch.
*
* @param system the satellite time scale
* @param reading the UTC reading
* @returns the scale's label, or null
*/
export declare function scaleLabelOfUtc(system: GnssSystem, reading: UtcReading): TimeScaleLabel | null;
/**
* A label on a satellite system's scale as a UTC reading.
*
* - TAI-based scales: the label plus the scale's fixed offset is TAI, read back through the
* leap-second table; inside an inserted second the reading is second 60.
* - `GLO`: the label itself is the UTC reading; a second 60 stands only where the table lists an
* insertion.
* - `null` before the scale's epoch, for a second-60 label on a continuous scale, and for a `GLO`
* second 60 on a day with no insertion.
*
* @param system the satellite time scale
* @param label the scale's label
* @returns the UTC reading, or null
*/
export declare function utcOfScaleLabel(system: GnssSystem, label: TimeScaleLabel): UtcReading | null;