Delta Days Calculator in Python

if __name__ == '__main__':
print("Elon San")

"""
This programme works on the basic principle of adding days by steps . Firstly Two cases arise ie. Same Year or Different
Year

For Same Year We Calculate up to The Last Day of The Month then add the number of days(31/30/28/29) till the final month
Then just simply add the number of days in the final month

For Different Year We Calculate up to Last day on initial month then to the last month of the initial year . Then up to
the Final Year

considering leap(365/366) Then to the final month . Lastly just add up the days in the final month

DONE !!
"""


def delta_days_calculator(date_initial, date_final):

temp_list = date_initial.split(".", 2)
if len(temp_list) != 3:
print("!!<Invalid Date/Format>!!")
exit()

day_i = int(temp_list[0])
month_i = int(temp_list[1])
year_i = int(temp_list[2])

leap_err = year_i % 4

temp_list = date_final.split(".", 2)
if len(temp_list) != 3:
print("!!<Invalid Date/Format>!!")

day_f = int(temp_list[0])
month_f = int(temp_list[1])
year_f = int(temp_list[2])

if year_i == year_f:
if month_i > month_f:
print(f"{date_initial} comes after {date_final}")
exit()

if year_f < year_i:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()

if year_i < 0 or year_f < 0:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()
if month_i > 12 or month_f > 12:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()

if month_i in [1, 3, 5, 7, 8, 10, 12] and day_i > 31:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()
if month_i in [4, 6, 9, 11] and day_i > 30:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()
if month_i == 2 and day_i > 29 and leap_err == 0:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()
if month_i == 2 and day_i > 28 and leap_err != 0:
print(f"!!! Invalid Entry \nDate : {date_initial} doesn't exist")
exit()

if month_f in [1, 3, 5, 7, 8, 10, 12] and day_f > 31:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()
if month_f in [4, 6, 9, 11] and day_f > 30:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()
if month_f == 2 and day_f > 29 and leap_err == 0:
print(f"!!! Invalid Entry Date {date_initial} doesn't exist")
exit()
if month_f == 2 and day_f > 28 and leap_err != 0:
print(f"!!! Invalid Entry \nDate : {date_initial} doesn't exist")
exit()

result = 0

if year_i == year_f:
if month_i == month_f:
if month_i in [1, 3, 5, 7, 8, 10, 12]:
temporary = day_f - day_i
result = result + temporary

if month_i in [4, 6, 9, 11]:
temporary = day_f - day_i
result = result + temporary

if month_i == 2:
if leap_err == 0:
temporary = day_f - day_i
result = result + temporary

elif leap_err != 0:
temporary = day_f - day_i
result = result + temporary

else:
if month_i in [1, 3, 5, 7, 8, 10, 12]:
temporary = 31 - day_i
result = result + temporary

if month_i in [4, 6, 9, 11]:
temporary = 30 - day_i
result = result + temporary

if month_i == 2:
if leap_err == 0:
temporary = 29 - day_i
result = result + temporary

elif leap_err != 0:
temporary = 28 - day_i
result = result + temporary

month_i = month_i + 1

while month_i < month_f:
if month_i in [1, 3, 5, 7, 8, 10, 12]:
result = result + 31

if month_i in [4, 6, 9, 11]:
result = result + 30

if month_i == 2:
if leap_err == 0:
result = result + 29

elif leap_err != 0:
result = result + 28

month_i += 1

result = result + day_f

else:
if month_i in [1, 3, 5, 7, 8, 10, 12]:
temporary = 31 - day_i
result = result + temporary

if month_i in [4, 6, 9, 11]:
temporary = 30 - day_i
result = result + temporary

if month_i == 2:
if leap_err == 0:
temporary = 29 - day_i
result = result + temporary

elif leap_err != 0:
temporary = 28 - day_i
result = result + temporary

month_i = month_i + 1
while month_i <= 12:
if month_i in [1, 3, 5, 7, 8, 10, 12]:
result = result + 31

if month_i in [4, 6, 9, 11]:
result = result + 30

if month_i == 2:
if leap_err == 0:
result = result + 29

elif leap_err != 0:
result = result + 28

month_i += 1

year_i = year_i + 1
while year_i < year_f:
if leap_err == 0:
result = result + 366
else:
result = result + 365

year_i += 1

month_i = 1

if month_i == month_f:
result = result + day_f

else:
while month_i < month_f:
if month_i in [1, 3, 5, 7, 8, 10, 12]:
result = result + 31

if month_i in [4, 6, 9, 11]:
result = result + 30

if month_i == 2:
if leap_err == 0:
result = result + 29

elif leap_err != 0:
result = result + 28
month_i += 1

result = result + day_f

if result == 0:
return f"{date_final} is Tomorrow"
elif result == -1:
return f"{date_initial}={date_final}"
else:
return f"The Number of Days between {date_initial} and {date_final} is \t<{result - 1}>"