See http://pobox.com/~djb/libtai/tai64.html for the latest version of this document. TAI64 D. J. Bernstein, djb@pobox.com 19980222 1. Introduction Today's UNIX systems, and many Internet protocols, store times as signed 32-bit integers representing the number of seconds since the beginning of 1970. This format will expire in 2038. Other systems, and other protocols, store times as unsigned 32-bit integers representing the number of seconds since 1900. This format will expire in 2036. This document defines a 64-bit format, TAI64, suitable for use in new systems and protocols. TAI64 represents a few hundred billion years of real time with 1-second precision. 2. The TAI64 timescale TAI stands for Temps Atomique International, the current international real time standard. One TAI second is defined as the duration of 9192631770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the cesium atom. (TAI also specifies a frame of reference; further discussion of relativity is outside the scope of this document.) TAI64 defines integer labels, between 0 and 2^64, for particular seconds of real time. If 2^62 <= n < 2^63 then label n refers to the TAI second beginning exactly n - 2^62 seconds after the beginning of 1970 TAI. If 0 <= n < 2^62 then label n refers to the TAI second beginning exactly 2^62 - n seconds before the beginning of 1970 TAI. For example, label 4611686018427387904 refers to the second beginning at the start of 1 January 1970 TAI. Label 4611686018427387903 refers to the previous second; label 4611686018427387905 refers to the next second. Labels 2^63 and larger are currently reserved for future extensions. Under many cosmological theories, the labels under 2^63 are adequate to cover the entire expected lifespan of the universe; in this case no extensions will be necessary. 3. The TAI64 format A TAI64 label is stored or communicated in eight 8-bit bytes in big-endian format. This means that bytes b0 b1 b2 b3 b4 b5 b6 b7 represent the label b0 * 2^56 + b1 * 2^48 + b2 * 2^40 + ... + b7. For example, bytes 64 0 0 0 0 0 0 0 represent the second that began 1970 TAI. Bytes 63 255 255 255 255 255 255 255 represent the previous second; bytes 64 0 0 0 0 0 0 1 represent the next second. Bytes 64 0 0 0 52 53 54 55 represent 3 October 1997 18:15:19 TAI, also known as 3 October 1997 18:14:48 UTC. 4. Handling fractional seconds One-second precision is inadequate for many applications. This section defines 96-bit and 128-bit formats, TAI64N and TAI64NA, with nanosecond and attosecond precision respectively. A TAI64N label refers to a TAI nanosecond. It has two parts: (1) a second count, meaning a TAI64 label; (2) a nanosecond count, meaning an integer between 0 and 999999999 inclusive. It is stored in twelve 8-bit bytes, with the TAI64 label followed by the nanosecond count in big-endian format. A TAI64NA label refers to a TAI attosecond. It has three parts: (1) a second count; (2) a nanosecond count; (3) an attosecond count, meaning an integer between 0 and 999999999 inclusive. It is stored in sixteen 8-bit bytes, with the TAI64 label followed by the nanosecond count in big-endian format and then the attosecond count in big-endian format.