Finds the day of the week on any date after 1582 AD according to the Gregorian calendar.
Original formula can be found from:
http://gmmentalgym.blogspot.com.tr/2011/03/day-of-week-for-any-date-revised.html#ndatebasics
About the Gregorian calendar: