Example #1
0
def calculate_remaining_space(event, date, width):
    """
    Returns the remaining space for the event title for the row which contains date
    """
    start = first_day_of_week(date)
    end = last_day_of_week(date)

    if event.start.as_date == end.as_date:
        return width

    if event.start.as_date > start.as_date:
        start = event.start
    else:
        width -= 2*PADDING_START
    if event.end.as_date < end:
        end = event.end
    else:
        width -= PADDING_END

    width -= PADDING_TITLE_LEFT

    remaining_space = 0
    for date in iter_date_range(start, end):
        remaining_space += width
    return remaining_space
Example #2
0
def rel_event_size_in_week(event1, event2, date):
    """
    Returns the relative size of two events in the week containing date.
    """

    weekstart = first_day_of_week(date)
    weekend = last_day_of_week(date)

    if event1.start < weekstart:
        event1_start = weekstart
    else:
        event1_start = event1.start

    if event2.start < weekstart:
        event2_start = weekstart
    else:
        event2_start = event2.start

    if event1.end > weekend:
        event1_end = weekend
    else:
        event1_end = event1.end

    if event2.end > weekend:
        event2_end = weekend
    else:
        event2_end = event2.end


    if event1_start > event2_start:
        start = event1_start
    else:
        start = event2_start


    return (event1_end - start), (event2_end - start)