曜日を得る方法(1:月曜 2:火曜 … 7:日曜)
int dayofweek(
int y, /* y > 1752 or so */
int m, /* 1 <= m <= 12 */
int d)
{
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
int w;
if (m < 3) {
y--;
}
w = (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
if ((w % 7) == 0) { /* 0 = Sunday */
w = 7;
}
return w;
}