---
name: "datetime"
section: "3"
platform: "linux"
package: "qmail"
version: "1.06-6.2~deb10u1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/datetime"
---

# datetime(3)

convert between TAI labels and seconds

## NAME

datetime - convert between TAI labels and seconds

## SYNTAX

**#include \<datetime.h\>**

void **datetime\_tai**(&*dt*,*t*);

datetime\_sec **datetime\_untai**(&*dt*);

struct datetime *dt*;\
 datetime\_sec *t*;

## DESCRIPTION

International Atomic Time, TAI, is the fundamental unit for time measurements. TAI has one label for every second of real time, without complications such as leap seconds.

A struct datetime variable, such as *dt*, stores a TAI label. *dt**.year*** is the year number minus 1900; *dt**.mon*** is the month number, from 0 (January) through 11 (December); *dt**.mday*** is the day of the month, from 1 through 31; *dt**.hour*** is the hour, from 0 through 23; *dt**.min*** is the minute, from 0 through 59; *dt**.sec*** is the second, from 0 through 59; *dt**.wday*** is the day of the week, from 0 (Sunday) through 6 (Saturday); *dt**.yday*** is the day of the year, from 0 through 365.

The **datetime** library supports more convenient TAI manipulation with the datetime\_sec type. A datetime\_sec value, such as *t*, is an integer referring to the *t*th second after the beginning of 1970 TAI. The first second of 1970 TAI was 0; the next second was 1; the last second of 1969 TAI was -1. The difference between two datetime\_sec values is a number of real-time seconds.

**datetime\_tai** converts a datetime\_sec to a TAI label.

**datetime\_untai** reads a TAI label (specifically *dt**.year***, *dt**.mon***, *dt**.mday***, *dt**.hour***, *dt**.min***, and *dt**.sec***) and returns a datetime\_sec.

## SEE ALSO

[now(3)](/now/3.md)
