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

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

int leapsecs_sub (uint64_t *t)
{
  uint64_t u = *t ;
  uint64_t d = 0 ;
  unsigned int i = 0 ;
  int hit = 0 ;
  for (; i < leapsecs_table_len ; i++)
  {
    if (u < leapsecs_table[i]) break ;
    if (u == leapsecs_table[i]) hit = 1 ;
    else d++ ;
  }
  *t = u - d ;
  return hit ;
}