def _trunc_el_planning(el_planning, starttime, endtime):
    """Modify (start, stop) tuple that are not within the (starttime, endtime) interval """
    if len(el_planning) > 0:
        el_planning.sort()
        i = 0
        while True:
            if i == len(el_planning):
                break
            start, stop = el_planning[i]
            if stop < starttime or start > endtime:
                el_planning.remove((start, stop))
            elif start < starttime:
                if stop < endtime:
                    el_planning.remove((start, stop))
                    el_planning.append((starttime, stop))
                else:
                    el_planning.remove((start, stop))
                    el_planning.append((starttime, endtime))
            elif stop > endtime:
                el_planning.remove((start, stop))
                el_planning.append((start, endtime))
            else:
                i += 1
            if i == len(el_planning):
                break
        el_planning.sort()
