Exemplo n.º 1
0
def get_month_agenda(model, queryset, start_date):
    """
    Get list of events that will occur in the given week.

    :param queryset: EventInstance queryset
    :param start_date: period start_date
    :type start_date: datetime.datetime()
    :return: data dictionary
    """
    start_date = datetime(start_date.year, start_date.month, 1)
    end_date = utils.date_to_datetime(utils.add_months(start_date.date(), 1),
                                      'max')
    return {
        'start_date':
        start_date,
        'end_date':
        end_date,
        'scope':
        'Month',
        'items':
        model.objects.in_date_range(start_date,
                                    end_date).filter(event__in=queryset),
        'next_date':
        utils.date_to_datetime(utils.add_months(start_date.date(), 1)),
        'previous_date':
        utils.date_to_datetime(utils.remove_months(start_date.date(), 1)),
    }
Exemplo n.º 2
0
def get_year_range(start_date):
    """
    Get the start and end datetimes for the year
    :param start_date: period start_date
    :type start_date: datetime.datetime()
    :return: tuple start_datetime, end_datetime
    """
    start_date = datetime(start_date.year, 1, 1)
    end_date = utils.date_to_datetime(utils.add_months(start_date, 12), 'max')
    return start_date, end_date