Created
March 25, 2016 15:23
-
-
Save taddeimania/765fcc32fef6399eddd2 to your computer and use it in GitHub Desktop.
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
# Find day of the week in python 3 | |
from enum import Enum | |
class DayOfWeek(Enum): | |
Sunday = 0 | |
Monday = 1 | |
Tuesday = 2 | |
Wednesday = 3 | |
Thursday = 4 | |
Friday = 5 | |
Saturday = 6 | |
def get_day_of_week(year, month, day): | |
month_table = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4] | |
year -= 1 if month < 3 else 0 | |
return DayOfWeek(int((year + year / 4 - year / 100 + year / 400 + month_table[month - 1] + day) % 7)) | |
print(get_day_of_week(1990, 4, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment