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 / fromjul2.c next >
Text File  |  1993-04-01  |  1KB  |  33 lines

  1.  
  2. /* ------------- Function FromJul2 ------------- */
  3. /* Function to convert a Julian day number to    */
  4. /* its corresponding Gregorian calendar date     */
  5. /* components (*month, *day, *year).             */
  6. /* ALGORITHM: Faster adaption of Fortran code in */
  7. /*            H. Fliegl and T. Van Flanders,     */
  8. /*            Communications of the ACM, Vol 11, */
  9. /*            No. 10, Oct. 1968, page 657        */
  10. /* RETURN:    Nothing, updates variables pointed */
  11. /*            to by month, day and year.         */
  12. /* --------------------------------------------- */
  13. void FromJul2(long julday,int *month,int *day,
  14.               int *year)
  15. {
  16.    int  t2,t4,mo,yr;
  17.    long tl;
  18.  
  19.    tl=julday+68569L;
  20.    t2=(int)((tl<<2)/146097L);
  21.    tl=tl-((146097L*(long)t2+3L)>>2);
  22.    yr=(int)(4000L*(tl+lL)/1461001L);
  23.    t4=(int)(tl-(1461L*(long)yr>>2)+31);
  24.    mo=80*t4/2447;
  25.    *day=(int)(t4-2447*mo/80);
  26.    t4=mo/11;
  27.    *month=(int)(mo+2-12*t4);
  28.    *year=100*(t2-49)+yr+t4;
  29.  
  30.    return;
  31. }
  32.  
  33.