Files
libucore/src/ucore_dayofweek.c
T
2012-10-29 23:07:32 +01:00

19 lines
322 B
C

int
uc_day_of_week(int day, int month, int year)
{
int cent;
/* adjust months so February is the last one */
month -= 2;
if (month < 1) {
month += 12;
--year;
}
/* split by century */
cent = year / 100;
year %= 100;
return ((26 * month - 2) / 10 + day + year
+ year / 4 + cent / 4 + 5 * cent) % 7;
}