I am trying to find out when someone will turn 1 billion seconds old. the user inputs when they were born. These values are then converted to seconds and then I add 1 billion seconds and convert back into a date. However, when I enter certain dates, python seems to mess up. Such an example is 1993/11/05 00:00:00 where python says the user will turn in the 0th month.
Note I cant use if/else or datetime.
Heres my code:
YEARSEC=(12*30*24*3600)
MONTHSEC=(3600*24*30)
DAYSEC=(24*3600)
HOURSEC=3600
MINUTESEC=60
year=int(input("Please enter the year in which you were born: "))
month=int(input("Please enter the month you were born: "))
day=int(input("Please enter the day you were born: "))
hour=int(input("Please enter the hour you were born: "))
minute=int(input("Please enter the minute you were born: "))
second=int(input("Please enter the second you were born: "))
year_calc=(year*YEARSEC)
month_calc=(month*MONTHSEC)
day_calc=(day*DAYSEC)
hour_calc=(hour*HOURSEC)
minute_calc=(minute*MINUTESEC)
s=(1000000000+year_calc+month_calc+day_calc+hour_calc+minute_calc+second)
year_num=int((s/YEARSEC))
s=(s-(year_num*YEARSEC))
month_num=int((s/MONTHSEC))
s=(s-(month_num*MONTHSEC))
day_num=int((s/DAYSEC))
s=(s-(DAYSEC*day_num))
hour_num=int((s/HOURSEC))
s=(s-(HOURSEC*hour_num))
minute_num=int((s/MINUTESEC))
s=(s-(MINUTESEC*minute_num))
print("You will turn 1 000 000 000 seconds old on: %04d/%02d/%02d %02d:%02d:%02d" %(year_num,month_num,day_num,hour_num,minute_num,s))
Though I have not test it all, I think you can not get Dec and day 30.
You should plus 1 to
day_numandmonth_numcause month and day start from 1 not 0.