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

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*             ADDJULE(X,X,X)        */
  4. /*                    */
  5. /* Functionality:            */
  6. /*    Adds julian days to a date and  */
  7. /*     creates the new date.        */
  8. /* Arguments:                */
  9. /*    0: The date to be added to.    */
  10. /*       This is in the form MM/DD/YY.*/
  11. /*    1: The number of days to add.    */
  12. /*    2: The resulting date.        */
  13. /* Functions used:            */
  14. /*     EFACTOR(),GETJULE(),JULE2DATE() */
  15. /* Returns: Nothing            */
  16. /* Author: John Callicotte        */
  17. /* Date created/modified: 09/01/88    */
  18. /*--------------------------------------*/
  19.  
  20. void addjule(a,b,c)
  21. int b;
  22. char a[8],c[8];
  23. {
  24.         int maxx,jules,year;
  25.         year=(a[6]-48)*10+a[7]-48;    /* Get first date's year */
  26.         jules=getjule(a)+b;        /* Figure new julian days */
  27.  
  28. A1:     maxx=365;
  29.         if (!efactor(year,4))        /* Is this leap year? */
  30.             maxx++;            /* Yes, 366 days/year */
  31.  
  32.         if (jules<=maxx)        /* Are the number of julian days */
  33.         goto A2;            /* less than the days/year? */
  34.  
  35.         jules-=maxx;            /* Subtract from the total the */
  36.                     /* number of days/year.        */
  37.  
  38.         ++year;                /* Increment the year */
  39.         goto A1;
  40.  
  41. A2:     jule2date(jules,c,year);    /* Create the new date */
  42. }
  43.