def conf_primary(class_result, ordinal):
    """
    Identify the confidence of the primary cover class for the given
    ordinal day. The days between and around segments identified through the
    classification process comprise valid segments for this. They also receive
    differing values based on if they occur at the beginning/end or if they are
    between classified segments.

    <- .... |--seg 1--| ...... |--seg 2--| .... ->
        0      val        100    val      0

    Args:
        class_result: ordered list of dicts return from pyclass classification
        ordinal: ordinal day to calculate from

    Returns:
        int
    """
    ret = 0

    if ordinal > 0:
        prev_end = 0

        for segment in class_result:

            if segment['start_day'] <= ordinal <= segment['end_day']:
                ret = int(max(segment['class_probs'][0]) * 100)
                break

            elif prev_end < ordinal < segment['start_day']:
                ret = 100
                break

            prev_end = segment['end_day']

    return ret