suitcase

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

nowutc.c (631B)


      1 #include <stdio.h>
      2 #include <tai/leapsecs.h>
      3 #include <tai/tai.h>
      4 #include <tai/taia.h>
      5 #include <tai/caltime.h>
      6 
      7 struct taia now;
      8 struct tai sec;
      9 struct caltime ct;
     10 
     11 char x[TAIA_FMTFRAC];
     12 
     13 int main(int argc, char **argv)
     14 {
     15   if (leapsecs_init() == -1) {
     16     fprintf(stderr,"utcnow: fatal: unable to init leapsecs\n");
     17     exit(111);
     18   }
     19     
     20   taia_now(&now);
     21   x[taia_fmtfrac(x,&now)] = 0;
     22 
     23   taia_tai(&now,&sec);
     24   caltime_utc(&ct,&sec,(int *) 0,(int *) 0);
     25 
     26   printf("%d-%02d-%02d %02d:%02d:%02d.%s\n"
     27     ,ct.date.year
     28     ,ct.date.month
     29     ,ct.date.day
     30     ,ct.hour
     31     ,ct.minute
     32     ,ct.second
     33     ,x
     34     );
     35 
     36   exit(0);
     37 }