home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 1 / FishNMoreVol1.bin / more / code_examples / librar / getjule.c < prev    next >
Text File  |  1989-02-08  |  1KB  |  45 lines

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*              GETJULE(X)              */
  4. /*                    */
  5. /* Functionality:            */
  6. /*    Gets the julian day from a date.*/
  7. /* Arguments:                */
  8. /*    0: The date to convert.        */
  9. /* Returns: The number of julian days.    */
  10. /* Functions used:            */
  11. /*    EFACTOR()            */
  12. /* Author: John Callicotte        */
  13. /* Date created/modified: 09/01/88    */
  14. /*                    */
  15. /*--------------------------------------*/
  16.  
  17. getjule(a)
  18. char a[8];
  19. {
  20.         int j,year,month,jules,MN[12];
  21.         jules=0;
  22.         MN[0]=31;    /* Initializes the month arrays with number of days */
  23.         MN[1]=28;    /* per month.                        */
  24.         MN[2]=31;
  25.         MN[3]=30;
  26.         MN[4]=31;
  27.         MN[5]=30;
  28.         MN[6]=31;
  29.         MN[7]=31;
  30.         MN[8]=30;
  31.         MN[9]=31;
  32.         MN[10]=30;
  33.         MN[11]=31;
  34.         year=(a[6]-48)*10+a[7]-48;
  35.         month=(a[0]-48)*10+a[1]-48;
  36.         jules=(a[3]-48)*10+a[4]-48;
  37.         if (!efactor(year,4))        /* Leap year? */
  38.             ++MN[1];
  39.         if (month==1)        /* Is the month January? */
  40.             goto JULE;
  41.         for (j=0;j<month-1;j++)
  42.              jules+=MN[j];
  43. JULE:   return(jules);
  44. }
  45.