def parse_interval(interval):
    """
    Attepmt to parse an ISO8601 formatted ``interval``.

    Returns a tuple of ``datetime.datetime`` and ``datetime.timedelta``
    objects, order dependent on ``interval``.
    """
    a, b = str(interval).upper().strip().split('/')

    if a[0] is 'P' and b[0] is 'P':
        raise ParseError()

    if a[0] != 'P' and b[0] != 'P':
        return parse_date(a), parse_date(b)

    if a[0] is 'P':
        a = parse_duration(a)
    else:
        a = parse_date(a)

    if b[0] is 'P':
        b = parse_duration(b)
    else:
        b = parse_date(b)

    return a, b
def parse_interval ( interval ) : a , b = str ( interval ) . upper ( ) . strip ( ) . split ( '/' ) if a [ 0 ] is 'P' and b [ 0 ] is 'P' : raise ParseError ( ) if a [ 0 ] != 'P' and b [ 0 ] != 'P' : return parse_date ( a ) , parse_date ( b ) if a [ 0 ] is 'P' : a = parse_duration ( a ) else : a = parse_date ( a ) if b [ 0 ] is 'P' : b = parse_duration ( b ) else : b = parse_date ( b ) return a , b
Attepmt to parse an ISO8601 formatted ``interval``.

    Returns a tuple of ``datetime.datetime`` and ``datetime.timedelta``
    objects, order dependent on ``interval``.