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

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

void leapsecs_add (uint64_t *t, int hit)
{
  uint64_t u = *t - !!hit ;
  unsigned int i = 0 ;
  for (; i < leapsecs_table_len ; i++)
  {
    if (u < leapsecs_table[i]) break ;
    if (!hit || (leapsecs_table[i] < u)) ++u ;
  }
  *t = u ;
}