tai: International Atomic Time

TAI or Temps Atomique International (French for International Atomic Time), measures real time. One second of TAI time is a constant duration defined by cesium radiation. TAI has been measured continuously since 1955 and is the foundation of all civil time standards.

Data types

struct tai

Platform independent container for a TAI, time with second precision.

It holds a value between 0 inclusive and \(2^{64}\) exclusive. Applications are discouraged to look inside struct tai.

struct taia

Platform independent container for a TAIA, time with atto second precision.

It holds a value between 0 inclusive and \(2^{64}\) exclusive. The number is a multiple of \(10^{-18}\). Applicaitons are discouraged to look inside struct taia.

Public members

uint64_t tai.x

Number of TAI seconds.

struct tai taia.sec

Number of TAI seconds.

unsigned long taia.nano

Number of nano seconds \(0..99999999\)

unsigned long taia.atto

Number of atto seconds \(0..99999999\)

API

void tai_now(struct tai *t)

Returns the current time in TAI.

Note

It is assumed that the time() function returns a time that represents the number of TAI seconds since 1970-01-01 00:00:10 TAI.

void tai_add(struct tai *t, const struct tai *a, const struct tai *b)

Add two TAI and collect the results in t.

void tai_sub(struct tai *t, const struct tai *a, const struct tai *b)

Substract two TAI and collect the results in t.

int tai_cmp(const struct tai *a, const struct tai *b)

Compare two TAI, suitable for most sort functions.

void tai_pack(const struct tai *t, char *s)

Pack a TAI to string, suitable for disk storage or network usage.

void tai_unpack(struct tai *t, const char *s)

Unpack a TAI from string.

void taia_tai(const struct taia *ta, struct tai *t)

Retrieve the TAI seconds in struct taia.

void taia_now(struct taia *ta)

Returns the current time in TAI with atto second precision.

Note

The gettimeofday() function returns nano second precision (at best), although struc taia can hold atto second precision.

void taia_add(struct taia *ta, const struct taia *a, const struct taia *b)

Add two TAIA and collect the results in t.

void taia_sub(struct taia *ta, const struct taia *a, const struct taia *b)

Substract two TAIA and collect the results in t.

int taia_cmp(const struct taia *a, const struct taia *b)

Compare two TAIA, suitable for most sort functions.

void taia_pack(const struct taia *ta, char *s)

Pack a TAIA to string, suitable for disk storage or network usage.

void taia_unpack(struct taia *ta, const char *s)

Unpack a TAIA from string.