<tr><thstyle="width: 30px;"></th>{% for d in days if (d.index <5)or(d.lectures|length)> 0 %}<thstyle="min-width: 10em;"colspan="{{d.maxcol}}">{{ d.date.strftime("%A (%d.%m.%Y)") }}</th>{% endfor %}</tr>
{# display time in first row if its a full hour #}
{% if ((loop.index - 1) is divisibleby 4) %} <tdrowspan="4"style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %}
{% if ((time_index - 1) is divisibleby 4) %} <tdrowspan="4"style="vertical-align: top;">{{ t.strftime("%H:%M") }}</td> {% endif %}
{# iterate over days if if it is a working day or we have lectures on that day (optionaly skip weekends) #}
{% for d in days if (d.index <5)or(d.lectures|length)> 0 %}
{% for col in range(1,d.maxcol+1) %}
{# iterate over all lextures but only consider those that are in the current column and happen in the 15 min block #}
{% for l in d.lectures|selectattr('timetable_col','equalto',col) if (((l.time.time() > t) and (l.time.time() <times[time_loop.index+1]))!=(l.time.time() ==t))%}
{# time_index starts at 0 so we use it directly and do not do +1 #}
{% for l in d.lectures|selectattr('timetable_col','equalto',col) if ((l.time.time() >= t) and (l.time.time() <times[time_index]))%}