def year_view(request, year, template='swingtime/yearly_view.html', queryset=None):
    '''

    Context parameters:
    
    ``year``
        an integer value for the year in questin
        
    ``next_year``
        year + 1
        
    ``last_year``
        year - 1
        
    ``by_month``
        a sorted list of (month, occurrences) tuples where month is a
        datetime.datetime object for the first day of a month and occurrences
        is a (potentially empty) list of values for that month. Only months
        which have at least 1 occurrence is represented in the list
        
    '''
    year = int(year)
    queryset = queryset._clone() if queryset is not None else Occurrence.objects.select_related()
    occurrences = queryset.filter(
        models.Q(start_time__year=year) |
        models.Q(end_time__year=year)
    )

    def group_key(o):
        return datetime(
            year,
            o.start_time.month if o.start_time.year == year else o.end_time.month,
            1
        )

    return render(request, template, {
        'year': year,
        'by_month': [(dt, list(o)) for dt,o in itertools.groupby(occurrences, group_key)],
        'next_year': year + 1,
        'last_year': 1 - year
        
    })


#-------------------------------------------------------------------------------
dataset/ETHPy150Open dakrauth/django-swingtime/swingtime/views.py/year_view/swapped operands of `-`