Created
April 13, 2016 18:11
-
-
Save embayer/cbc0803e4014fed8c7a1b3918ba4573d to your computer and use it in GitHub Desktop.
get the day of week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_day_of_week(year, month, day): | |
month_table = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4] | |
if month < 3: | |
year = year - 1 | |
return (year + year / 4 - year / 100 + year / 400 + month_table[month - 1] + day) % 7 | |
print get_day_of_week(2016, 3, 25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment