# This program prompts the user for the year, month and day number.
# Then it prompts for the number of days to be added to this date.
# It then calculates the new date with the days added and displays
# the result. (in a year, month, day format)

# here we are reusing the functions that we have created to manage
# time and dates.
import timeOps

# before writing this code we determine exactly what steps we want
# to take to do this.  We don't write the code until we are certain
# how we are going to tackle this task/problem.

# Prompt for the date.  Since raw_input returns a string and we want
# an integer, we must cast the result to an integer using int() prior 
# to assigning it to the variables (year, month, day, and addAmt)
year = int(raw_input("Enter the Year as YYYY: "))
month = int(raw_input("Enter the Month as MM: "))
day = int(raw_input("Enter the Day as DD: "))
addAmt = int(raw_input("How many days do you want to add?"))

# Now we convert it to the Julian date.
julianDay = timeOps.ymdToJulian(year, month,day)

# Then we add the requested amount.
julianDay = julianDay + addAmt

# If we have crossed the year threshold, we must figure out
# which day of the following year it is (in julian date)
# and we must add one to the year.  We must take into
# consideration whether or not it is a leap year.
if timeOps.isLeap(year) == 1:
    daysInYear = 366
else:
    daysInYear = 365
    
if julianDay > daysInYear:
    year = year+1
    julianDay = julianDay - daysInYear

# Finally, we want to print the date in Month, day format.
timeOps.getYearDay(julianDay, year)

