import calendar


def get_month_selection(year, month, time_array):
    """Get the Boolean array that selects ‘year’-‘month’ from ‘time_array’.

    The month must be between 1 and 12.
    The time in ‘time_array’ must be in seconds since the Epoch.

    This function is useful for the selection of monthly maxima from a
    time series.
    """
    t_start = calendar.timegm((year, month, 1, 0, 0, 0, -1, -1, -1))
    if month == 12:
        t_end = calendar.timegm((year+1, 1, 1, 0, 0, 0, -1, -1, -1))
    else:
        t_end = calendar.timegm((year, month+1, 1, 0, 0, 0, -1, -1, -1))
    return (time_array >= t_start) & (time_array < t_end)