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
End Enum

Public Shared Function GetDayOfWeek(year As UInteger, month As Byte, day As Byte) As DayOfWeek
	Dim monthTable As Byte() = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}

	year -= CUInt(If((month < 3), 1, 0))

	Return CType((year + year \ 4 - year \ 100 + year \ 400 + monthTable(month - 1) + day) Mod 7, DayOfWeek)
End Function
								


Example

									Dim value = GetDayOfWeek(CUInt(DateTime.Now.Year), CByte(DateTime.Now.Month), 24)
								


Output

									Thursday