def parse_duration(duration, start=None, end=None):
    """
    Attepmt to parse an ISO8601 formatted duration.

    Accepts a ``duration`` and optionally a start or end ``datetime``.
    ``duration`` must be an ISO8601 formatted string.

    Returns a ``datetime.timedelta`` object.
    """
    if not start and not end:
        return parse_simple_duration(duration)

    if start:
        return parse_duration_with_start(start, duration)

    if end:
        return parse_duration_with_end(duration, end)
def parse_duration ( duration , start = None , end = None ) : if not start and not end : return parse_simple_duration ( duration ) if start : return parse_duration_with_start ( start , duration ) if end : return parse_duration_with_end ( duration , end )
Attepmt to parse an ISO8601 formatted duration.

    Accepts a ``duration`` and optionally a start or end ``datetime``.
    ``duration`` must be an ISO8601 formatted string.

    Returns a ``datetime.timedelta`` object.