# A python script to calculate the number of days 
# since your date of birth.
# Solved it as a assignment problem from the Udacity course site
# Though the solution is a lot different from theirs

def isleap(year):
    if year%400==0:
        return True
    elif year%100==0:           #got from wikipedia...the code for leap year
        return False
    elif year%4==0:
        return True
    else:
        return False

def daysleft(year,month,day):
    if isleap(year):
        daysOfMonths = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    else:
        daysOfMonths = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    x=daysOfMonths[month-1]-day
    for i in range(month,12):
        x=x+daysOfMonths[i]
    return x




def daysbefore(year,month,day):
    if isleap(year):
        return 366-daysleft(year,month,day)
    else:
        return 365-daysleft(year,month,day)

def daysBetweenDates(year1, month1, day1, year2, month2, day2):
    if year1==year2:
        return abs(daysleft(year1,month1,day1)-daysleft(year2,month2,day2))
    else:
        first=daysleft(year1,month1,day1)
        last=daysbefore(year2,month2,day2)
        middle=0
        while year1+1<year2:
            middle+=daysleft(year1+1,1,0)
            year1+=1
        return first+middle+last
def mykalakari():
    print "Hey Prasanth!!!"
    query=raw_input("Want to know how long you were living since your birthday in terms of days?\
                If yes then type y or type n if not interested  ")
    if query=='y':
        year1=int(raw_input("Enter your birthday year  eg. 1947  "))
        month1=int(raw_input("Enter your month  eg. 8 for september  "))
        day1=int(raw_input("Enter your date  "))
        year2=int(raw_input("Enter todays year  "))
        month2=int(raw_input("Enters todays month  "))
        day2=int(raw_input("Enters todays date  "))
        print("The number of days you are a burden to this world :P is  ")
        print daysBetweenDates(year1, month1, day1, year2, month2, day2)
        print "Wow!!!  You sure are growing old"
        a=raw_input("type something to exit")
    elif query=='n':
        print "You are fit for nothing...I wasted so much of my time to write this code for you....and all \
               you do is ignore it...you"
        a=raw_input("type something to exit")
        
        
    else:
        print "I didn't understand what you typed..."
        print "repeating again"
        mykalakari()


mykalakari()
