blob: 68fa6992cb5a7cf6a94870a4dc7af5c80579689b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
/* ISC license. */
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
int tain_from_ntp (tain_t *a, uint64_t u)
{
tai_t secs = { .x = u >> 32 } ;
if (secs.x <= 0x7FFFFFFFUL) secs.x |= ((uint64_t)1 << 32) ;
secs.x += TAI_MAGIC ;
secs.x -= NTP_OFFSET ;
if (!tai_from_utc(&secs, secs.x)) return 0 ;
a->sec = secs ;
a->nano = ((u & 0xFFFFFFFFUL) * 1000000000) >> 32 ;
return 1 ;
}
|