Skip to content

Instantly share code, notes, and snippets.

@embayer
Created April 13, 2016 18:11
Show Gist options
  • Save embayer/cbc0803e4014fed8c7a1b3918ba4573d to your computer and use it in GitHub Desktop.
Save embayer/cbc0803e4014fed8c7a1b3918ba4573d to your computer and use it in GitHub Desktop.
get the day of week
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