< previous page page_185 next page >

Page 185
7.3
JD0_to_julian_proleptic ()
The routine JD02julp.c (Listing 7.2) converts a Julian Day number, expressed as a type double, into the corresponding Julian proleptic calendar date.
(continued)
Listing 7.2
   m = 0;
   stop = 0;
   date.year = 0;
   while (stop == 0)
         {
         m++;


         if (r < tab [m])
            {
            date.month = m;
            date.day = r - tab [m - 1] + 1;
            stop = 1;
            }
         }


   return (date);
}
/*
   Auxiliary routine for JD0_to_julian_proleptic (). Assigns the month
   and day part of a DATE_INFO structure, given the remainder of modulo
   1461 division, for a Julian common year.


   Each set of 1461 days consists of one leap year and three common years.
   The second, third and fourth years are the common years.
*/


struct DATE_INFO j2jp_aux_2 (int r)
{
   int m, stop;
   int tab [13] = {0, 31, 59, 90, 120, 151, 181,
                   212, 243, 273, 304, 334, 365};
   struct DATE_INFO date;


   m = 0;
   stop = 0;
   date.year = 0;


   while (stop == 0)
         {
         m++;
         if (r < tab [m])
            {
            date.month = m;
            date.day = r - tab [m - 1] + 1;
            stop = 1;
            }
         }


   return (date);
}

 
< previous page page_185 next page >