Parse input into an interval of two times, specifying start and end time, in ISO 8601 format, for example:

    ``(2017-01-15:T00:00:00, 2017-01-16:T23:59:59)``

    The input time can have the following formats, which will be parsed as:

    * `YYYY-MM-DD` -> `[YYYY-MM-DD:T00:00:00, YYYY-MM-DD:T23:59:59]`
    * `YYYY-MM-DDThh:mm:ss` -> `[YYYY-MM-DDThh:mm:ss, YYYY-MM-DDThh:mm:ss]`
    * list or tuple of two dates in form `YYYY-MM-DD` -> `[YYYY-MM-DDT00:00:00, YYYY-MM-DDT23:59:59]`
    * list or tuple of two dates in form `YYYY-MM-DDThh:mm:ss` -> `[YYYY-MM-DDThh:mm:ss, YYYY-MM-DDThh:mm:ss]`,
    * `None` -> `[default_start_date from config.json, current date]`

    All input times can also be specified as `datetime` objects. Instances of `datetime.date` will be treated as
    `YYYY-MM-DD` and instance of `datetime.datetime` will be treated as `YYYY-MM-DDThh:mm:ss`.

    :param time: An input time
    :type time: str or datetime.datetime
    :return: interval of start and end date of the form `YYYY-MM-DDThh:mm:ss`
    :rtype: (str, str)
    :raises: ValueError

def parse_time_interval(time):
    """ Parse input into an interval of two times, specifying start and end time, in ISO 8601 format, for example:

    ``(2017-01-15:T00:00:00, 2017-01-16:T23:59:59)``

    The input time can have the following formats, which will be parsed as:

    * `YYYY-MM-DD` -> `[YYYY-MM-DD:T00:00:00, YYYY-MM-DD:T23:59:59]`
    * `YYYY-MM-DDThh:mm:ss` -> `[YYYY-MM-DDThh:mm:ss, YYYY-MM-DDThh:mm:ss]`
    * list or tuple of two dates in form `YYYY-MM-DD` -> `[YYYY-MM-DDT00:00:00, YYYY-MM-DDT23:59:59]`
    * list or tuple of two dates in form `YYYY-MM-DDThh:mm:ss` -> `[YYYY-MM-DDThh:mm:ss, YYYY-MM-DDThh:mm:ss]`,
    * `None` -> `[default_start_date from config.json, current date]`

    All input times can also be specified as `datetime` objects. Instances of `datetime.date` will be treated as
    `YYYY-MM-DD` and instance of `datetime.datetime` will be treated as `YYYY-MM-DDThh:mm:ss`.

    :param time: An input time
    :type time: str or datetime.datetime
    :return: interval of start and end date of the form `YYYY-MM-DDThh:mm:ss`
    :rtype: (str, str)
    :raises: ValueError
    """
    if time is None or time is OgcConstants.LATEST:
        date_interval = (SHConfig().default_start_date, get_current_date())
    else:
        if isinstance(time, (str, datetime.date)):
            date_interval = (parse_time(time), ) * 2
        elif isinstance(time, (tuple, list)) and len(time) == 2:
            date_interval = (parse_time(time[0]), parse_time(time[1]))
        else:
            raise ValueError('Time must be a string/datetime object or tuple/list of 2 strings/datetime objects')

    if 'T' not in date_interval[0]:
        date_interval = (date_interval[0] + 'T00:00:00', date_interval[1])
    if 'T' not in date_interval[1]:
        date_interval = (date_interval[0], date_interval[1] + 'T23:59:59')

    if date_interval[1] < date_interval[0]:
        raise ValueError('Start of time interval is larger than end of time interval')

    return date_interval