suitcase

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

easter.c (623B)


      1 #include <stdio.h>
      2 #include <tai/caldate.h>
      3 
      4 char *dayname[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } ;
      5 
      6 char out[101];
      7 
      8 int main(int argc, char **argv)
      9 {
     10   struct caldate cd;
     11   long day;
     12   int weekday;
     13   int yearday;
     14   int i;
     15 
     16   while (*++argv) {
     17     cd.year = atoi(*argv);
     18     if (cd.year > 0) {
     19       caldate_easter(&cd);
     20       day = caldate_mjd(&cd);
     21       caldate_frommjd(&cd,day,&weekday,&yearday);
     22       if (caldate_fmt((char *) 0,&cd) + 1 >= sizeof out) exit(1);
     23       out[caldate_fmt(out,&cd)] = 0;
     24       printf("%s %s  yearday %d  mjd %d\n",dayname[weekday],out,yearday,day);
     25     }
     26   }
     27   exit(0);
     28 }