@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.
63 lines • 3.19 kB
TypeScript
import { UtcReading } from "./utcReading.js";
/** TAI − UTC by date: `at[i]` (epoch ns, 00:00:00 UTC on a month's first day) starts `taiMinusUtc[i]`. */
export interface LeapSecondSteps {
/** Epoch nanoseconds at which each row's TAI − UTC takes effect, strictly increasing. */
readonly at: readonly bigint[];
/** TAI − UTC in whole seconds from `at[i]` until `at[i + 1]`. */
readonly taiMinusUtc: readonly bigint[];
}
/**
* IERS Earth Orientation Center, Leap_Second.dat (https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat),
* updated through IERS Bulletin C 72, 6 July 2026. Closed: CGPM 2026 Resolution 5 makes UTC
* continuous from 20 May 2027, and Bulletin C 72 rules out the end of December 2026. After the last
* row TAI − UTC stays 37 s. Checked weekly against IERS by scripts/leap-seconds.mjs.
*/
export declare const LEAP_SECOND_STEPS: LeapSecondSteps;
/**
* TAI of a UTC reading, as label nanoseconds (the TAI wall clock read as if UTC), or `null` when
* the reading has no TAI instant.
*
* - `null` before the first row: TAI − UTC was not a whole number of seconds before 1972 (BIPM
* Annual Report vol. 15, Table 2).
* - A second-60 reading is valid only in the second before a positive step, where it maps to
* that inserted second: old offset + 1 s (ITU-R TF.460-6 Annex 1 §2.2).
* - An ordinary reading inside a deleted second (before a negative step) has no instant.
* - No upper bound: after the last row its offset holds.
*
* @param steps the leap-second table
* @param reading the UTC reading
* @returns TAI label nanoseconds, or null
*/
export declare function taiOfUtc(steps: LeapSecondSteps, reading: UtcReading): bigint | null;
/**
* The UTC reading of a TAI instant given as label nanoseconds, or `null` before the table's
* first TAI instant (1972-01-01T00:00:10 TAI).
*
* - Inside an inserted second the reading is second 60: its `epochNanoseconds` is the
* `…T23:59:59.f` instant Temporal would clamp `…:60.f` to.
* - A negative step needs no special case: the deleted second has no TAI instant to map.
*
* @param steps the leap-second table
* @param tai TAI label nanoseconds
* @returns the UTC reading, or null
*/
export declare function utcOfTai(steps: LeapSecondSteps, tai: bigint): UtcReading | null;
/**
* The UTC reading of step `index`'s own second, the second before `at[index]` (ITU-R TF.460-6
* Annex 1 §2.2): for a positive step the inserted `…T23:59:60` (a second-60 reading); for a
* negative step the omitted `…T23:59:59` (an ordinary reading of its label).
*
* @param steps the leap-second table
* @param index a row index from 1
* @returns the reading of that step's second
*/
export declare function stepReading(steps: LeapSecondSteps, index: number): UtcReading;
/**
* Index of the first step (row 1 on) that starts after a UTC reading, or −1 when there is none.
* A second-60 reading counts as the instant one second later, so its own step is behind it.
*
* @param steps the leap-second table
* @param reading the UTC reading
* @returns the row index, or −1
*/
export declare function nextStepIndex(steps: LeapSecondSteps, reading: UtcReading): number;