>REBOL [
> Title: "day of the Week"
>]
>;figure out the number of days in this month and print
>; figuring out how many days in month
>; one way that seems intutive if I could do somthing like=20
The 'standard', if there is such a thing, for figuring out
the day of the week is "Zeller's Congruence". His formula
might help you out.
Sorry that I didn't take the time to convert it to Rebol.
Would like to see it that way if some one is so inclined.
/* Zeller's Congruence: From "Acta Mathematica #7, Stockholm, 1887.
Determine the day of the week give the year, month, and the
day of the month; which are passed in the structure 'utc'
return( 0 = Sunday...6=Saturday ) and also set utc->wday
J = Century (ie 19), K = Year (ie 91), q = Day of the month, m = Month
March = month #3....December = month #12,
January = month #13, February = month #14 OF THE PREVIOUS YEAR.
[q + [((m + 1) * 26 ) / 10] + K + (K / 4) + (J / 4) - (2 * J)] % 7
Because of the "% 7" term, -(2*J), and +(5*J) give the same answer.
*/
UINT weekday( gmt )
struct utc *gmt;
{
UINT mth, year, cent;
register UINT temp;
year = gmt->year;
mth = gmt->month;
if( mth < 3 )
{
mth += 12;
--year;
}
cent = year / 100; /* 19th, 20th, or 21th etc century */
year %= 100; /* Tens of years (00->99) */
temp = gmt->day; /* Start with the day of the month */
temp += (((mth + 1) * 26) / 10); /* Advance to the start of the month */
temp += year; /* [K] Add in the year */
temp += (year / 4); /* [K/4] Correct for leap years */
/* Because of the "% 7" term, -(2*J), and +(5*J) give the same answer: */
temp += (cent * 5); /* [J*5] Correct for centuries */
temp += (cent / 4); /* [J/4] Give extra day ever 400 years */
temp %= 7; /* 7 days in a week */
if( !temp ) /* Wrap Saturday to be the last day of week */
temp = 7;
temp -= 1; /* 0 = Sunday...6=Saturday */
gmt->wday = temp;
return( temp );
}