Day Of Week

This algorithm finds the current day of week according to the input date.



									public enum DayOfWeek
{
	Sunday,
	Monday,
	Tuesday,
	Wednesday,
	Thursday,
	Friday,
	Saturday
}

public static DayOfWeek GetDayOfWeek(uint year, byte month, byte day)
{
	byte[] monthTable = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };

	year -= (uint)((month < 3) ? 1 : 0);

	return (DayOfWeek)((year + year / 4 - year / 100 + year / 400 + monthTable[month - 1] + day) % 7);
}
								


Example

									DayOfWeek value = GetDayOfWeek((uint)DateTime.Now.Year, (byte)DateTime.Now.Month, 24);
								


Output

									Thursday