描述
补充函数next_day代码给出输入日期的下一天,is_leap_year用于判断给定年份是否为闰年。
# 闰年判定:
# 1.能被400整除
# 2.不能被100整除但是可以被4整除
def is_leap_year(year):
if year % 400 == 0:
return True
elif year % 100 == 0:
return False
elif year % 4 == 0:
return True
else:
return False
def next_day(year, month, day):
if is_leap_year(year) == True:
if month == 1:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 2:
if day == 29:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 3:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 4:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 5:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 6:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 7:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 8:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 9:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 10:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 11:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 12:
if day == 31:
day = 1
month = 1
year += 1
else:
day += 1
return year, month, day
else:
if month == 1:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 2:
if day == 28:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 3:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 4:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 5:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 6:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 7:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 8:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 9:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 10:
if day == 31:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 11:
if day == 30:
day = 1
month += 1
return year, month, day
else:
day += 1
return year, month, day
elif month == 12:
if day == 31:
day = 1
month = 0
year += 1
else:
day += 1
return year, month, day
year, month, day = map(int, input().split('/'))
year, month, day = next_day(year, month, day)
print(f"The next day is {year}-{month}-{day}.")