home *** CD-ROM | disk | FTP | other *** search
- /*****
- datename()
-
- This function returns the day of the week for a date. It is based
- on Zeller's Congruence.
-
- Argument list: int month the month
- int day the day
- int year the year
-
- Return value: char * a pointer to the day of the week
-
- *****/
-
- char *datename(int day, int month, int year)
- {
- static char *days[] = {"Sun.", "Mon.", "Tues", "Wed.",
- "Thur", "Fri.", "Sat.", "Sun."};
-
- int index;
-
- if (year < 100) /* If century is missing */
- year += 1900;
-
- if (month > 2) { /* Everything is from February */
- month -= 2;
- } else {
- month += 10;
- year--;
- }
-
- index = ((13 * month - 1) / 5) + day + (year % 100) + ( (year % 100) / 4)
- + ((year / 100) / 4) - 2 * (year / 100) + 77;
- index = index - 7 * (index / 7);
-
- return days[index];
- }
-