suitcase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

leapsecs_sub.c (438B)


      1 #include <tai/leapsecs.h>
      2 #include <tai/tai.h>
      3 
      4 /* XXX: breaks tai encapsulation */
      5 
      6 extern struct tai *leapsecs;
      7 extern int leapsecs_num;
      8 
      9 int leapsecs_sub(struct tai *t)
     10 {
     11   int i;
     12   uint64 u;
     13   int s;
     14 
     15   if (leapsecs_init() == -1) return 0;
     16 
     17   u = t->x;
     18   s = 0;
     19 
     20   for (i = 0;i < leapsecs_num;++i) {
     21     if (u < leapsecs[i].x) break;
     22     ++s;
     23     if (u == leapsecs[i].x) { t->x = u - s; return 1; }
     24   }
     25 
     26   t->x = u - s;
     27   return 0;
     28 }