tai64n 1 user commands nosh
tai64n filter to prepend external TAI64N timestamps
`tai64n` files

## Description

`tai64n` reads a series of lines. To each line it prefixes an `@` character, a TAI64N timestamp in external form (16 hexadecimal digits of seconds and 8 hexadecimal digits of nanoseconds), and a space.

If no files are supplied, `tai64n` reads from its standard input until EOF. Otherwise it processes each named file in turn. In both cases it writes to its standard output.

A trailing newline is silently added to any file (or to standard input) that ends with a partial line.

The timestamp is the time when `tai64n` processes the beginning of a line, which is slightly after it has read the beginning of that line. `tai6n` uses the `CLOCK_REALTIME` clock of the clock_gettime 2 system call. On many systems this has nanosecond resolution.

`tai64n` attempts to generate correct TAI64N timestamps. On a Linux system where it detects an Olson "right" timezone currently in use, it knows that the system clock is TAI seconds since the Epoch and performs a simple conversion. On other Linux systems, and on BSDs, it assumes that the system clock is UTC seconds since the Epoch and attempts to correct for (known) UTC leap seconds in order to determine TAI.

`tai64n` uses the C/C++ runtime library for output, and therefore has the normal C/C++ stream buffering semantics. It uses the read 2 library function for input, however. To duplicate the GNU and BSD C/C++ runtime libraries' behaviours, it explicitly flushes the output's buffer whenever it is about to read more input and that input is the beginning of a new line.

## Compatibility

daemontools' and daemontools-encore's tai64n 1 uses a timer with only microsecond resolution, and for the same events will thus produce different timestamps to `tai64n`.

See the timestamps section of the nosh Guide for detailed information on the differences from daemontools, daemontools-encore, and other toolsets in how `tai64nlocal` handles TAI.

## Author

Jonathan de Boyne Pollard