def detection_length(detection):
    """Calculates total duration of detection based on it's occurrences."""
    ret_val = 0.0
    for occ in detection.get("occs",[]):
        ret_val += occ["se"]-occ["ss"]
    return ret_val