def angle_offset(base, angle):
    """
    Given a base bearing and a second bearing, return the offset in degrees.

    Positive offsets are clockwise/to the right, negative offsets are
    counter-clockwise/to the left.
    """
    # rotate the angle towards 0 by base
    offset = angle - base

    if offset <= -180:
        # bring it back into the (-180, 180] range
        return 360 + offset

    if offset > 180:
        return offset - 360

    return offset