suitcase

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

caltime_utc.c (587B)


      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_utc(struct caltime *ct, struct tai *t, int *pwday, int *pyday)
      9 {
     10   struct tai t2 = *t;
     11   uint64 u;
     12   int leap;
     13   long s;
     14 
     15   /* XXX: check for overfow? */
     16 
     17   leap = leapsecs_sub(&t2);
     18   u = t2.x;
     19 
     20   u += 58486;
     21   s = u % 86400ULL;
     22 
     23   ct->second = (s % 60) + leap; s /= 60;
     24   ct->minute = s % 60; s /= 60;
     25   ct->hour = s;
     26 
     27   u /= 86400ULL;
     28   caldate_frommjd(&ct->date,/*XXX*/(long) (u - 53375995543064ULL),pwday,pyday);
     29 
     30   ct->offset = 0;
     31 }