suitcase

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

caltime_tai.c (461B)


      1 #include <tai/tai.h>
      2 #include <tai/leapsecs.h>
      3 #include <tai/caldate.h>
      4 #include <tai/caltime.h>
      5 
      6 /* XXX: breaks tai encapsulation */
      7 
      8 void caltime_tai(struct caltime *ct, struct tai *t)
      9 {
     10   long day;
     11   long s;
     12 
     13   /* XXX: check for overflow? */
     14 
     15   day = caldate_mjd(&ct->date);
     16 
     17   s = ct->hour * 60 + ct->minute;
     18   s = (s - ct->offset) * 60 + ct->second;
     19 
     20   t->x = day * 86400ULL + 4611686014920671114ULL + (long long) s;
     21 
     22   leapsecs_add(t,ct->second == 60);
     23 }