home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_08 / hill / tojul2.c < prev   
Text File  |  1993-04-01  |  782b  |  27 lines

  1.  
  2. /* ------------- Function ToJul2 --------------- */
  3. /* Function to convert a Gregorian calendar date */
  4. /* (month,day,year) to a Julian day number.      */
  5. /* ALGORITHM: Faster adaption of Fortran code in */
  6. /*            H. Fliegl and T. Van Flanders,     */
  7. /*            Communications of the ACM, Vol 11  */
  8. /*            No. 10, Oct. 1968, page 657        */
  9. /* RETURNS: Julian day number, as long int.      */
  10. /* --------------------------------------------- */
  11. long ToJul2(int month,int day,int year)
  12. {
  13.    int  tl=0;
  14.    long jul_day;
  15.  
  16.    if (month<3)
  17.       tl--;
  18.  
  19.    jul_day=(long)day-32075L
  20.            +((1461L*(long)(year+4800+tl))>>2)
  21.            +(long)(367*(month-2-tl*12)/12)
  22.            -(3*((year+4900+tl)/100)>>2);
  23.  
  24.     return (jul_day);
  25. }
  26.  
  27.