import calendar


def increment_day(day):
    """Takes a YYYY-MM-DD formatted string and increments it by one day, keeping
    in mind months, years, leap years, etc."""
    date = day.split("-")
    date[2] = str(int(date[2]) + 1) #increment day
    #perform normal month checks
    if ((date[2] == '31' and int(date[1]) in {4, 6, 9, 11}) or
            (date[2] == '32' and int(date[1]) in {1, 3, 5, 7, 8, 10, 12})):
        date[2] = '1'
        date[1] = str(int(date[1])+1)
    #Roll over year if neccessary
    if date[1] == '13':
        date[1] = '01'
        date[0] = str(int(date[0])+1)
    #Handle February, including leap year
    if ((calendar.isleap(int(date[0])) and date[1] == '02' and date[2] == '30') or
            (date[1] == '02' and date[2] == '29')):
        date[1] = '03'
        date[2] = '01'
    #return incremented date
    return date[0]+'-'+date[1]+'-'+date[2]