I'm trying to write a simple code which gets the birth date of the user and prints how many days so far they have lived. Although it's not that precise (I didn't add the month day conditions to determine how many days exactly each month includes), there seems to be more serious calculation problem I'm not getting right. It somehow shows way more days than it's supposed to. I wonder why.
Here's my code:
print('Enter your birth date in the following format: \nDD/MM/YYYY')
birth_date = input()
birth_day = int(birth_date.split('/')[0])
birth_month = int(birth_date.split('/')[1])
birth_year = int(birth_date.split('/')[2])
current_year = 2021
current_month = 3
current_day = 8
extra_days = ((current_year - birth_year) // 4) + ((current_year - birth_year) // 400) + 1
this_year_days = 67 #Jan=31, Feb=28, Mar=8th
birth_year_days = birth_day + ((birth_month - 1)*30)
total_days = ((current_year - birth_year)*365) + (this_year_days + birth_year_days) + extra_days
print(total_days)
When I give the same dates to online age calculation websites they return less amounts than what I get shown here. For example, for 26/04/2000
the internet shows 7622 days
, but my code returns 7853 days
. I know I'm not having the best solution to this problem, but I can't figure out what I have not taken into consideration.
I'd appreciate it in advance if anyone could help me with this.