def METHOD_NAME(tally, status_durations, start, end):
    for sd in status_durations:
        if sd.start_time < end and (sd.finish_time or end) > start:
            duration = min(sd.finish_time or end, end) - max(sd.start_time, start)
            assert duration >= datetime.timedelta(0)
            tally["idle_%s" % sd.status.value.lower()] += duration