kkaefer/chrono.js — Issue #1: Please support TAI64, TAI64N, and TAI64NA
Author: dfc
Created: 2011-10-18 02:54:58+00:00
State: open

The following description is stolen from: http://cr.yp.to/libtai/tai64.html

## TAI64 labels and external TAI64 format

A TAI64 label is an integer between 0 and 2\^64 referring to a
particular second of real time. Integer *s* refers to

- the TAI second beginning exactly 2\^62 - *s* seconds before the
beginning of 1970 TAI, if *s* is between 0 inclusive and 2\^62
exclusive; or
- the TAI second beginning exactly *s* - 2\^62 seconds after the
beginning of 1970 TAI, if *s* is between 2\^62 inclusive and 2\^63
exclusive.

Integers 2\^63 and larger are reserved for future extensions. Under many
cosmological theories, the integers under 2\^63 are adequate to cover
the entire expected lifetime of the universe; in this case no extensions
will be necessary.

A TAI64 label is normally stored or communicated in *external TAI64
format*, consisting of 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 + b3 \* 2\^32 + b4 \* 2\^24 + b5 \* 2\^16 +
b6 \* 2\^8 + b7.

For example, bytes 3f ff ff ff ff ff ff ff hexadecimal represent the
second that ended 1969 TAI; bytes 40 00 00 00 00 00 00 00 hexadecimal
represent the second that began 1970 TAI; bytes 40 00 00 00 00 00 00 01
hexadecimal represent the following second. Bytes 40 00 00 00 2a 2b 2c
2d hexadecimal represent 1992-06-02 08:07:09 TAI, also known as
1992-06-02 08:06:43 UTC.

## TAI64N labels and external TAI64N format

A TAI64N label refers to a particular nanosecond of real time. It has
two parts:

1. a [TAI64 label](#tai64) and
2. an integer, between 0 and 999999999 inclusive, counting nanoseconds
from the beginning of the second represented by the TAI64 label.

A TAI64N label is normally stored or communicated in *external TAI64N
format*, consisting of twelve 8-bit bytes. The first eight bytes are the
TAI64 label in [external TAI64 format](#tai64). The last four bytes are
the nanosecond counter in big-endian format.

## TAI64NA labels and external TAI64NA format

A TAI64NA label refers to a particular attosecond of real time. It has
two parts:

1. a [TAI64N label](#tai64n) and
2. an integer, between 0 and 999999999 inclusive, counting attoseconds
from the beginning of the nanosecond represented by the TAI64N
label.

A TAI64NA label is normally stored or communicated in *external TAI64NA
format*, consisting of sixteen 8-bit bytes. The first twelve bytes are
the TAI64N label in [external TAI64N format](#tai64n). The last four
bytes are the attosecond counter in big-endian format.

## Historical notes

Many network protocols and filesystems store timestamps in the original
UNIX format: a signed 32-bit integer representing the number of seconds
since the beginning of 1970. This format will expire in 2038. Other
protocols store timestamps as unsigned 32-bit integers representing the
number of seconds since 1900; this format will expire in 2036.

TAI64 was defined in July 1997 for use in new protocols. TAI64N and
TAI64NA were defined at the same time for protocols where 1-second
precision is insufficient.