CelestialCalendar 1.0.0 · unreleased development @ 67a7c4c79a4a4a6aa7e703c9e6f0039ae34bee82
Loading...
Searching...
No Matches
astro::leap_second Namespace Reference

Classes

struct  LeapSecondEntry
 One step of the ΔAT table: from start_utc (inclusive), TAI − UTC is tai_minus_utc seconds. More...

Functions

constexpr auto tai_minus_utc (const std::chrono::year_month_day &utc_ymd) -> double
 Look up ΔAT = TAI − UTC for the given UTC calendar date.
constexpr auto tt_minus_utc (const std::chrono::year_month_day &utc_ymd) -> double
 TT − UTC in seconds for the given UTC calendar date: ΔAT + 32.184 s, exact by definition.
constexpr auto utc_to_tt (const calendar::Datetime &utc_dt) -> calendar::Datetime
 Convert a calendar::Datetime in UTC to a new calendar::Datetime in TT.
constexpr auto tt_to_utc (const calendar::Datetime &tt_dt) -> calendar::Datetime
 Convert a calendar::Datetime in TT to a new calendar::Datetime in UTC.

Variables

constexpr double TT_MINUS_TAI_SEC
 TT − TAI in seconds. Exact by definition: TT = TAI + 32.184 s.
constexpr std::array< LeapSecondEntry, 28 > LEAP_SECOND_TABLE
 The ΔAT (TAI − UTC) step table, from the start of modern UTC (1972-01-01) onwards. Each new entry is one inserted leap second.
constexpr std::chrono::year_month_day MODERN_UTC_START
 The first day of modern UTC. Before it this project has no UTC to model: civil datetimes are treated as UT1 and converted through ΔT instead.

Function Documentation

◆ tai_minus_utc()

auto astro::leap_second::tai_minus_utc ( const std::chrono::year_month_day & utc_ymd) ->double
nodiscardconstexpr

Look up ΔAT = TAI − UTC for the given UTC calendar date.

Parameters
utc_ymdThe UTC calendar date.
Returns
ΔAT, in seconds.
Exceptions
std::invalid_argumentif the date predates modern UTC (1972-01-01).

◆ tt_minus_utc()

auto astro::leap_second::tt_minus_utc ( const std::chrono::year_month_day & utc_ymd) ->double
nodiscardconstexpr

TT − UTC in seconds for the given UTC calendar date: ΔAT + 32.184 s, exact by definition.

Parameters
utc_ymdThe UTC calendar date.
Returns
TT − UTC, in seconds.
Exceptions
std::invalid_argumentif the date predates modern UTC (1972-01-01).

◆ tt_to_utc()

auto astro::leap_second::tt_to_utc ( const calendar::Datetime & tt_dt) ->calendar::Datetime
nodiscardconstexpr

Convert a calendar::Datetime in TT to a new calendar::Datetime in UTC.

Parameters
tt_dtThe datetime in TT.
Returns
The datetime in UTC.
Exceptions
std::invalid_argumentIf a pre-1972 datetime is invalid or the shift leaves the representable years.

ΔAT steps on the UTC date, which is only known once the conversion is done — so guess with the TT date, then refine once with the resulting UTC date. One refinement settles any step crossing: consecutive steps are at least half a year apart, while TT − UTC is under two minutes. Before modern UTC (1972-01-01) this falls back to UT1 through ΔT, mirroring utc_to_tt; past the table's last entry ΔAT is held at 37 s (see LEAP_SECOND_TABLE).

Note
Instants inside an inserted leap second (the unrepresentable 23:59:60) land in the first second of the following UTC day, duplicating it — on that 1 s TT interval the conversion is not invertible, and utc_to_tt(tt_to_utc(tt)) returns tt plus one second.

◆ utc_to_tt()

auto astro::leap_second::utc_to_tt ( const calendar::Datetime & utc_dt) ->calendar::Datetime
nodiscardconstexpr

Convert a calendar::Datetime in UTC to a new calendar::Datetime in TT.

Parameters
utc_dtThe datetime in UTC.
Returns
The datetime in TT.
Exceptions
std::invalid_argumentIf a pre-1972 datetime is invalid or the shift leaves the representable years.

TT = UTC + ΔAT + 32.184 s. Before modern UTC (1972-01-01) the input is treated as UT1 and converted through ΔT instead — the rubber-second UTC of 1960-1971 is not modelled. The seam at 1972-01-01 is ΔT(1972.0) − 42.184 s, well under a second. Past the table's last entry ΔAT is held at 37 s (see LEAP_SECOND_TABLE).

Note
A Datetime cannot carry an inserted second 23:59:60 itself; the conversion is defined on the representable instants around it.

Variable Documentation

◆ LEAP_SECOND_TABLE

std::array<LeapSecondEntry, 28> astro::leap_second::LEAP_SECOND_TABLE
inlineconstexpr

The ΔAT (TAI − UTC) step table, from the start of modern UTC (1972-01-01) onwards. Each new entry is one inserted leap second.

No leap second has been announced since 2017, and CGPM Resolution 4 (2022) decided to discontinue them by 2035 — past the last entry, ΔAT is held at its final value.

See also
SOFA issue 2023-10-11 dat.c; IERS Bulletin C remains the leap-update authority.

◆ MODERN_UTC_START

std::chrono::year_month_day astro::leap_second::MODERN_UTC_START
inlineconstexpr

The first day of modern UTC. Before it this project has no UTC to model: civil datetimes are treated as UT1 and converted through ΔT instead.

◆ TT_MINUS_TAI_SEC

double astro::leap_second::TT_MINUS_TAI_SEC
inlineconstexpr

TT − TAI in seconds. Exact by definition: TT = TAI + 32.184 s.

See also
IAU 1991 Resolution A4.