Skip to content

Instantly share code, notes, and snippets.

@se7enack
Last active May 20, 2025 16:00
Show Gist options
  • Save se7enack/c033ff43404da4c21d69021f4994b618 to your computer and use it in GitHub Desktop.
Save se7enack/c033ff43404da4c21d69021f4994b618 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
year = input("Please enter a 4 digit year: ")
cenFloats = [2, 0, 5, 3]
weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
def getMinorFloat(x):
return ((x+int(x/4))%7)
def getCenturyFloat(x):
return x % len(cenFloats)
def getWeekday(year):
century = year // 100
decade = year % 100
minorFloat = getMinorFloat(decade)
centuryFloat = cenFloats[getCenturyFloat(century)]
return weekdays[(centuryFloat + minorFloat) % 7]
try:
year = int(year)
if not 1582 <= int(year) <= 9999:
print("The Gregorian calendar was instituted by Pope Gregory XIII in 1582.\nOnly 4 digit number years excepted starting from 1582 on.")
else:
print(f"10/31/{year} was a {getWeekday(year)}")
except:
print("Only 4 digit number years excepted starting from 1582 on.")
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment