home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------*/
- /* */
- /* JULEDIFF(X,X) */
- /* */
- /* Returns the julian difference of two */
- /* dates passed in the arguments. The */
- /* number returned will never be nega- */
- /* tive. */
- /* */
- /* Written by John Callicotte */
- /* */
- /*--------------------------------------*/
- # include "string.h"
- julediff(a,b)
- char a[8],b[8];
- {
- int j,x,year[2],jules[2];
- char date[2][8];
- x=strncmp(a,b,8);
- if (!x)
- return(0);
- if (x>0){
- for (j=0;j<8;j++){
- date[0][j]=b[j];
- date[1][j]=a[j];
- }
- }
- else{
- for (j=0;j<8;j++){
- date[0][j]=a[j];
- date[1][j]=b[j];
- }
- }
- for (j=0;j<2;j++){
- year[j]=(date[j][6]-48)*10+date[j][7]-48;
- jules[j]=getjule(date[j]);
- }
- if (year[0]==year[1])
- return(jules[1]-jules[0]);
- x=365-jules[0];
- if (!efactor(year[0],4))
- x++;
- if (year[0]==year[1]-1)
- return(x+jules[1]);
- for (j=year[0]+1;j<year[1];j++){
- x+=365;
- if (!efactor(j,4))
- x++;
- }
- x+=jules[1];
- return(x);
- }