#ifndef KEKS_DECTAI_H
#define KEKS_DECTAI_H

#include <stddef.h>
#include <time.h> // IWYU pragma: keep // struct timespec

#include "err.h"

// TEXINFO: KEKSTAI64ToTimespec
// @deftypefun {enum KEKSErr} KEKSTAI64ToTimespec @
//     (struct timespec *tv, const unsigned char *buf, const size_t len)
// Convert TAI64* value from @var{buf} to @var{ts} structure.
// @code{KEKSErrTAI64InPast} error is returned if value represents time
// before 1970. Some systems support those dates, but not guaranteed to.
// @code{KEKSErrTAI64TooBig} error is returned when time is out of bounds
// of @code{time_t} representation. @code{KEKSErrTAI64BadAsec} is
// returned if TAI64NA is provided, because currently no systems support
// attoseconds.
// @end deftypefun
enum KEKSErr
KEKSTAI64ToTimespec(struct timespec *ts, const unsigned char *buf, const size_t len);

// TEXINFO: KEKSTimespecToUTC
// @deftypefun {enum KEKSErr} KEKSTimespecToUTC (struct timespec *ts)
// Convert TAI stored in @var{ts} structure to UTC. @code{KEKSErrTAI64InPast}
// error is returned if value represents time before 1970.
// @end deftypefun
enum KEKSErr
KEKSTimespecToUTC(struct timespec *ts);

#endif // KEKS_DECTAI_H
