.. index:: single: time_scales_data
.. _time_scales_data/0:

.. rst-class:: right

**object**

``time_scales_data``
====================

Bundled and override data plus constants for UTC/TAI/TT/UT1/TDB/TCG/TCB conversions.

| **Availability:** 
|    ``logtalk_load(time_scales(loader))``

| **Author:** Paulo Moura
| **Version:** 0:2:0
| **Date:** 2026-02-26

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Uses:**
|    :ref:`logtalk <logtalk/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: load_leap_seconds_override/1
.. _time_scales_data/0::load_leap_seconds_override/1:

``load_leap_seconds_override/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Loads leap-second override data from a file containing ``leap(UnixSeconds,OffsetSeconds).`` terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``load_leap_seconds_override(File)``
| **Mode and number of proofs:**
|    ``load_leap_seconds_override(+atom)`` - ``one``

| **Remarks:**

    - Term format: Each term must be of the form ``leap(UnixSeconds,OffsetSeconds).``.
    - Term ordering: Terms must be sorted by increasing ``UnixSeconds``.
    - Value constraints: ``UnixSeconds`` must be an integer greater than or equal to ``63072000`` and ``OffsetSeconds`` must be a non-decreasing integer sequence.


------------

.. index:: clear_leap_seconds_override/0
.. _time_scales_data/0::clear_leap_seconds_override/0:

``clear_leap_seconds_override/0``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Clears leap-second override data and reverts to bundled data.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``clear_leap_seconds_override`` - ``one``


------------

.. index:: leap_seconds_source/1
.. _time_scales_data/0::leap_seconds_source/1:

``leap_seconds_source/1``
^^^^^^^^^^^^^^^^^^^^^^^^^

Returns the active leap-seconds data source as ``bundled`` or ``override``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``leap_seconds_source(Source)``
| **Mode and number of proofs:**
|    ``leap_seconds_source(-atom)`` - ``one``


------------

.. index:: leap_seconds_entries/1
.. _time_scales_data/0::leap_seconds_entries/1:

``leap_seconds_entries/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns the active leap-seconds data as an ordered list of ``leap(UnixSeconds,OffsetSeconds)`` terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``leap_seconds_entries(Entries)``
| **Mode and number of proofs:**
|    ``leap_seconds_entries(-list)`` - ``one``


------------

.. index:: save_leap_seconds_entries/1
.. _time_scales_data/0::save_leap_seconds_entries/1:

``save_leap_seconds_entries/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Saves the active leap-seconds data to a file using ``leap(UnixSeconds,OffsetSeconds).`` terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``save_leap_seconds_entries(File)``
| **Mode and number of proofs:**
|    ``save_leap_seconds_entries(+atom)`` - ``one``


------------

.. index:: load_dut1_override/1
.. _time_scales_data/0::load_dut1_override/1:

``load_dut1_override/1``
^^^^^^^^^^^^^^^^^^^^^^^^

Loads DUT1 override data from a file containing ``dut1(UnixSeconds,Numerator,Denominator).`` terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``load_dut1_override(File)``
| **Mode and number of proofs:**
|    ``load_dut1_override(+atom)`` - ``one``

| **Remarks:**

    - Term format: Each term must be of the form ``dut1(UnixSeconds,Numerator,Denominator).``.
    - Term ordering: Terms must be sorted by increasing ``UnixSeconds``.
    - Value constraints: ``UnixSeconds`` and ``Numerator`` must be integers; ``Denominator`` must be a positive integer; ``UnixSeconds`` must be greater than or equal to ``63072000``.


------------

.. index:: clear_dut1_override/0
.. _time_scales_data/0::clear_dut1_override/0:

``clear_dut1_override/0``
^^^^^^^^^^^^^^^^^^^^^^^^^

Clears DUT1 override data and reverts to bundled data.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``clear_dut1_override`` - ``one``


------------

.. index:: dut1_source/1
.. _time_scales_data/0::dut1_source/1:

``dut1_source/1``
^^^^^^^^^^^^^^^^^

Returns the active DUT1 data source as ``bundled`` or ``override``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``dut1_source(Source)``
| **Mode and number of proofs:**
|    ``dut1_source(-atom)`` - ``one``


------------

.. index:: dut1_entries/1
.. _time_scales_data/0::dut1_entries/1:

``dut1_entries/1``
^^^^^^^^^^^^^^^^^^

Returns the active DUT1 data as an ordered list of ``dut1(UnixSeconds,Numerator,Denominator)`` terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``dut1_entries(Entries)``
| **Mode and number of proofs:**
|    ``dut1_entries(-list)`` - ``one``


------------

.. index:: save_dut1_entries/1
.. _time_scales_data/0::save_dut1_entries/1:

``save_dut1_entries/1``
^^^^^^^^^^^^^^^^^^^^^^^

Saves the active DUT1 data to a file using ``dut1(UnixSeconds,Numerator,Denominator).`` terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``save_dut1_entries(File)``
| **Mode and number of proofs:**
|    ``save_dut1_entries(+atom)`` - ``one``


------------

.. index:: leap_offset_at_utc_unix/2
.. _time_scales_data/0::leap_offset_at_utc_unix/2:

``leap_offset_at_utc_unix/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns the ``TAI-UTC`` offset in SI seconds for a given UTC Unix epoch second within the supported range.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``leap_offset_at_utc_unix(UnixSeconds,OffsetSeconds)``
| **Mode and number of proofs:**
|    ``leap_offset_at_utc_unix(+integer,-integer)`` - ``zero_or_one``


------------

.. index:: leap_effective_date/2
.. _time_scales_data/0::leap_effective_date/2:

``leap_effective_date/2``
^^^^^^^^^^^^^^^^^^^^^^^^^

Enumerates UTC effective dates for ``TAI-UTC`` offset changes and their resulting offset in SI seconds.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``leap_effective_date(UTCDateTime,OffsetSeconds)``
| **Mode and number of proofs:**
|    ``leap_effective_date(?compound,?integer)`` - ``zero_or_more``


------------

.. index:: tt_minus_tai/2
.. _time_scales_data/0::tt_minus_tai/2:

``tt_minus_tai/2``
^^^^^^^^^^^^^^^^^^

Returns the constant TT minus TAI offset as a rational value ``Numerator/Denominator`` seconds.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``tt_minus_tai(Numerator,Denominator)``
| **Mode and number of proofs:**
|    ``tt_minus_tai(-integer,-integer)`` - ``one``


------------

.. index:: dut1_offset_at_utc_unix/3
.. _time_scales_data/0::dut1_offset_at_utc_unix/3:

``dut1_offset_at_utc_unix/3``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns DUT1 (``UT1-UTC``) at a UTC Unix epoch second as a rational value ``Numerator/Denominator``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``dut1_offset_at_utc_unix(UnixSeconds,Numerator,Denominator)``
| **Mode and number of proofs:**
|    ``dut1_offset_at_utc_unix(+integer,-integer,-integer)`` - ``zero_or_one``


------------

.. index:: tdb_minus_tt_approx/3
.. _time_scales_data/0::tdb_minus_tt_approx/3:

``tdb_minus_tt_approx/3``
^^^^^^^^^^^^^^^^^^^^^^^^^

Returns an approximate ``TDB-TT`` offset in seconds for a TT instant represented by integer seconds and normalized fraction.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``tdb_minus_tt_approx(TTSeconds,Fraction,OffsetSeconds)``
| **Mode and number of proofs:**
|    ``tdb_minus_tt_approx(+integer,+compound,-float)`` - ``one``


------------

.. index:: tcg_minus_tt_approx/3
.. _time_scales_data/0::tcg_minus_tt_approx/3:

``tcg_minus_tt_approx/3``
^^^^^^^^^^^^^^^^^^^^^^^^^

Returns an approximate ``TCG-TT`` offset in seconds for a TT instant represented by integer seconds and normalized fraction.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``tcg_minus_tt_approx(TTSeconds,Fraction,OffsetSeconds)``
| **Mode and number of proofs:**
|    ``tcg_minus_tt_approx(+integer,+compound,-float)`` - ``one``


------------

.. index:: tcb_minus_tdb_approx/3
.. _time_scales_data/0::tcb_minus_tdb_approx/3:

``tcb_minus_tdb_approx/3``
^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns an approximate ``TCB-TDB`` offset in seconds for a TDB instant represented by integer seconds and normalized fraction.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``tcb_minus_tdb_approx(TDBSeconds,Fraction,OffsetSeconds)``
| **Mode and number of proofs:**
|    ``tcb_minus_tdb_approx(+integer,+compound,-float)`` - ``one``


------------

.. index:: tai_minus_utc_for_tai_unix/2
.. _time_scales_data/0::tai_minus_utc_for_tai_unix/2:

``tai_minus_utc_for_tai_unix/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns the ``TAI-UTC`` offset in SI seconds for a given TAI instant represented as Unix-like integer seconds.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``tai_minus_utc_for_tai_unix(TAISeconds,OffsetSeconds)``
| **Mode and number of proofs:**
|    ``tai_minus_utc_for_tai_unix(+integer,-integer)`` - ``zero_or_one``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

