def _spans(dates):
    """Get the consecutive spans from the given dates."""
    spans = []
    current_span = []
    prev = 0
    for date in dates:
        if date == prev + 1:
            current_span.append(date)
        else:
            spans.append(list(current_span))
            current_span.clear()
            current_span.append(date)
        prev = date
    spans.append(current_span)
    return list(filter(None, spans))
