package orsetto
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=9b654edb663ae697563f150824047052f3b1bf760398f24bce6350553f031f73c46b6337239a1acd871e61238597ea92046809e3358290ff14d6ba671b449085
doc/orsetto.cf/Cf_tai64n/index.html
Module Cf_tai64n
Computations with the Temps Atomique International (TAI) timescale.
Overview
This module (and its cognate Cf_tai64
) defines an abstract type and associated functions for computations with values representing epochs in the Temps Atomique International (TAI) timescale. Values are represented internally with the TAI64 format defined by Dan Bernstein, and support precision to the nearest nanosecond.
Functions are provided that:
- acquire the current time in TAI64N format.
- compare, add and subtract values.
- convert between TAI64N values and a portable external format called the "TAI64N label", which is essentially an array of twelve octets.
- convert between TAI64N values and the float values returned by the
Unix.gettimeofday
function.
Constants are also provided that define the boundaries of valid TAI64N representations.
Warning: This implementation obtains the current time of day using the POSIX gettimeofday()
function, which returns a value based on the UTC timescale (but with leap seconds "elided" in a way that makes conversions between POSIX time, Standard Time and TAI a perilous undertaking). See the Cf_stdtime
module for detail
Types
Functions
Equivalence and total order relations
include Cf_relations.Std with type t := t
Use compare a b
to compare a
and b
, returning 0
if the two values have equal ordering, 1
if a
precedes b
and -1
if a
succeeds b
.
val now : unit -> t
Returns the current time in TAI64N, obtained by reading the current time from the POSIX gettimeofday()
function, and adjusting for leap seconds. (Currently, the leap seconds table is hardcoded into the library, and the most recent leap second announcement was for Dec 31, 1998.)
val first : t
The earliest TAI epoch representable in the TAI64N format. The TAI64N label is 00000000 00000000 00000000
.
val last : t
The latest TAI epoch representable in the TAI64N format. The TAI64N label is 7fffffff ffffffff 3b9ac9ff
.
val compose : Cf_tai64.t -> int -> t
Use compose s ns
to compose a TAI64N value from a TAI64 value s
and an offset of ns
nanoseconds. Raises Invalid_argument
if the number of nanoseconds is not less than 1012.
val decompose : t -> Cf_tai64.t * int
Use decompose x
to separate the TAI64N value x
into a TAI64 value and an offset in nanoseconds.
val to_unix_time : t -> float
Converts a TAI64 value to a value consistent with the result of calling the Unix.gettimeofday
function.
val of_unix_time : float -> t
Converts a value consistent with the result of calling the Unix.gettimeofday
function into a TAI64N value.
val to_label : t -> string
Returns a string of 12 octets containing the TAI64N label corresponding to the TAI64N value of its argument.
val of_label : string -> t
Interprets the argument as a TAI64N label and returns the corresponding TAI64N value. Raises Cf_tai64.Label_error
if the label is not a valid TAI64N label.
Add seconds to a TAI64N value. Raises Oni_cf_tai64.Range_error
if the result is not a valid TAI64N value.