skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

leapsecs_sub.c (365B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/uint64.h>
      4 #include "djbtime-internal.h"
      5 
      6 int leapsecs_sub (uint64_t *t)
      7 {
      8   uint64_t u = *t ;
      9   uint64_t d = 0 ;
     10   unsigned int i = 0 ;
     11   int hit = 0 ;
     12   for (; i < leapsecs_table_len ; i++)
     13   {
     14     if (u < leapsecs_table[i]) break ;
     15     if (u == leapsecs_table[i]) hit = 1 ;
     16     else d++ ;
     17   }
     18   *t = u - d ;
     19   return hit ;
     20 }