/* *** weekday.c *** */ /* */ /* IBM - PC microsoft "C" */ /* */ /* function to determine the day of the week a given gregorian date */ /* falls on. Returns a 0 if successful or a -1 if not. */ /* */ /* WARNING - day must be declared to be at least 10 characters or a */ /* memory overwrite will occure. */ /* */ /* Written by L. Cuthbertson, March 1983 */ /* */ /* Rewritten at August 1986 by Petri Helenius, */ /* Sysop of Electric Empire */ /* (+358-0-874 5258) */ /*********************************************************************/ /* */ int weekday(indate,day) char indate[],day[]; { static *char days [7][10] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; int iday; long julian,gtoj(); /* get julian date */ if ((julian = gtoj(indate)) == (-1)) return(-1); /* calculate day of week */ iday = (julian-1) % 7; /* move weekday into character string */ strcpy(day,days[iday]); /* done */ return(0); }