I am trying to test a simple function to get a specific day of the week given a date, but every time I input the arguments the return value keeps coming out of none. As shown below, the code is not complete, but I am using a very specific date (Jan. 3, 1900) to get a desired output: Wednesday; this is in fact the weekday of that specific date.
def isYearLeap(year):
return year % 4 == 0 and (year % 400 == 0 or year % 100 != 0)
def dayOfYear(year, month, day):
century = int(str(year)[:2])
if century in [15, 19, 23]:
century_code = 3
elif century in [16, 20, 24]:
century_code = 2
elif century in [17, 21, 25]:
century_code = 0
elif century in [18, 22, 26]:
century_code = 5
yr = year % 100
b = yr // 12
c = yr % 12
d = c // 4
sum = century_code + yr + b + c + d
if sum >= 7:
while sum >= 7:
sum -= 7
days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
if sum in [0, 1, 2, 3, 4, 5, 6, 7]:
for day in range(0, 8):
if sum == day:
**year_dday = days[day]**
if month == 1 and isYearLeap(year) == False:
if day in [3, 10, 17, 24, 31]:
**return year_dday**
print(dayOfYear(1900, 1, 3))