Parse input time/date string into ISO 8601 string

    :param time_input: time/date to parse
    :type time_input: str or datetime.date or datetime.datetime
    :return: parsed string in ISO 8601 format
    :rtype: str

def parse_time(time_input):
    """ Parse input time/date string into ISO 8601 string

    :param time_input: time/date to parse
    :type time_input: str or datetime.date or datetime.datetime
    :return: parsed string in ISO 8601 format
    :rtype: str
    """
    if isinstance(time_input, datetime.date):
        return time_input.isoformat()  # datetime.date only returns date, datetime.datetime also returns time

    if len(time_input) < 8:
        raise ValueError('Invalid time string {}.\n'
                         'Please specify time in formats YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS'.format(time_input))
    time = dateutil.parser.parse(time_input)
    if len(time_input) <= 10:
        return time.date().isoformat()
    return time.isoformat()