home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
code_examples
/
librar
/
getjule.c
< prev
next >
Wrap
Text File
|
1989-02-08
|
1KB
|
45 lines
/*--------------------------------------*/
/* */
/* GETJULE(X) */
/* */
/* Functionality: */
/* Gets the julian day from a date.*/
/* Arguments: */
/* 0: The date to convert. */
/* Returns: The number of julian days. */
/* Functions used: */
/* EFACTOR() */
/* Author: John Callicotte */
/* Date created/modified: 09/01/88 */
/* */
/*--------------------------------------*/
getjule(a)
char a[8];
{
int j,year,month,jules,MN[12];
jules=0;
MN[0]=31; /* Initializes the month arrays with number of days */
MN[1]=28; /* per month. */
MN[2]=31;
MN[3]=30;
MN[4]=31;
MN[5]=30;
MN[6]=31;
MN[7]=31;
MN[8]=30;
MN[9]=31;
MN[10]=30;
MN[11]=31;
year=(a[6]-48)*10+a[7]-48;
month=(a[0]-48)*10+a[1]-48;
jules=(a[3]-48)*10+a[4]-48;
if (!efactor(year,4)) /* Leap year? */
++MN[1];
if (month==1) /* Is the month January? */
goto JULE;
for (j=0;j<month-1;j++)
jules+=MN[j];
JULE: return(jules);
}