summaryrefslogtreecommitdiff
path: root/src/libstddjb/utc_from_tai.c
blob: a0e087ebda931ccc028f7b6d59b9f547199f0947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* ISC license. */

#include <errno.h>
#include <skalibs/djbtime.h>
#include "djbtime-internal.h"

int utc_from_tai (uint64_t *u, tai_t const *t)
{
  int r = 1 ;
  uint64_t tt = t->x - 10 ;
  if (t->x < 10U) return (errno = EINVAL, 0) ;
  r += leapsecs_sub(&tt) ;
  *u = tt ;
  return r ;
}