Front page | perl.perl6.language.datetime |
Postings from August 2000
From: Mark-Jason Dominus
August 18, 2000 13:54
Message ID: firstname.lastname@example.org
TAI is an international time standard. It has a number of technical
advantages over UTC. One of these advantages is that it doesn't have
any silly truck with leap seconds.
Dan Bernstein has defined a time format called TAI64 which is based on
TAI. The format is very simple. TAI64 is almost compatible with Unix
epoch time. TAI64 has a resolution of one second and a range of about
300 billion years.
Bernstein has a small, good-quality library of code for manipulating
TAI64 values and for converting them to and from UTC or unix epoch
time. The library is in the public domain, so there can't be any
license or copyright objection to including it in Perl.
TAI64 has one-second precision, but there are extensions to it,
TAI64N and TAI64A, with nanosecond and attosecond precision. libtai
handles these extensions also.
libtai has functions to convert calendar dates and times (such as
"March 27 1823") into TAI values and back and to input and output date
and time strings. It has functions for addition, subtraction, and
comparison of TAI times. The interfce is simple and well-documented.
If we're going to standardize on a single time format for all
platforms, I wish we could choose a good format. Unix time runs out
The libtai blurb is at:
I've included this below.
Public-domain source code for libtai:
The spec for TAI64:
libtai is a library for storing and manipulating dates and times.
libtai supports two time scales: (1) TAI64, covering a few hundred
billion years with 1-second precision; (2) TAI64NA, covering the same
period with 1-attosecond precision. Both scales are defined in terms of
TAI, the current international real time standard.
libtai provides an internal format for TAI64, struct tai, designed for
fast time manipulations. The tai_pack() and tai_unpack() routines
convert between struct tai and a portable 8-byte TAI64 storage format.
libtai provides similar internal and external formats for TAI64NA.
libtai provides struct caldate to store dates in year-month-day form. It
can convert struct caldate, under the Gregorian calendar, to a modified
Julian day number for easy date arithmetic.
libtai provides struct caltime to store calendar dates and times along
with UTC offsets. It can convert from struct tai to struct caltime in
UTC, accounting for leap seconds, for accurate date and time display. It
can also convert back from struct caltime to struct tai for user input.
Its overall UTC-to-TAI conversion speed is 100x better than the usual
UNIX mktime() implementation.
This version of libtai requires a UNIX system with gettimeofday(). It
will be easy to port to other operating systems with compilers
supporting 64-bit arithmetic.
The libtai source code is in the public domain.
Re: TAI Time
by Mark-Jason Dominus
by Mark-Jason Dominus