# TAI-10 and UTC

## Keeping the time in TAI

All of the Bernstein softwares operate, and always have operated, in terms of TAI-10. This is where the operating system's kernel clock counts SI seconds since 1970-01-01 00:00:10 (proleptic) UTC and applications softwares are expected to use the Olson "right" (as opposed to "posix") timezone data files.

This does not apply just to the timekeeping utilities such as `clockadd` and `nowutc`, but also applies to the Internet publication tools such as `httpd` (which converts from system timestamps in TAI-10 to a human-readable timestamp in HTTP `Last-Modified:` headers).

Although the SNTP protocol uses UTC, not TAI, the `sntpclock` tool attempts to convert timestamps in the SNTP form to TAI timestamps as used by the system, if SNTP is the chosen form of time synchronization. `taiclock` and `taiclockd` synchronize directly in TAI-10.

TAI-10 timekeeping (except where `clockspeed` is in the mix) does not slew or smear leap seconds out, over periods of a day or longer; but rather provides (or at least makes best effort attempts to provide, in the face of hardware limitations) a guarantee that one second of the system clock is one SI second, leap second or otherwise.

## Leap seconds

The Olson "right" timezones have within them tables of when leap seconds (positive or negative) have occurred, so that the SI seconds counts are converted into broken-down clock dates and times the leap seconds are correctly accounted for.

Bernstein's softwares use Bernstein's own libtai library, which does not read Olson timezone files, but which instead has its own timezone table in the `/usr/local/etc/leapsecs.dat` file; which is much the same idea only in a file of its own.

This file is a machine-readable very simple table of leap seconds, a pre-compiled (and up-to-date as of 2025) form of which is built from a human-readable source file (named `source/leapsecs.txt`) when building from source and is packaged into one of the djbwares binary packages. (There is a very similar, although not quite identical, `leap-seconds.list` file in the source code of the timezone files, that is compiled into a binary form too.)

If for some reason this becomes out of date, the `leapsecs` tool can simply be used to compile a new `/usr/local/etc/leapsecs.dat` file by hand.