Arbeitskalender Tim Lappe

Mo
Di
Mi
Do
Fr
Sa
So
{% set currentMonth = null %} {% set currentWeek = null %} {% for day in days %} {# Check if month changed #} {% if currentMonth != day.date|date('F Y') %} {% set currentMonth = day.date|date('F Y') %}
{{ day.date|date('F Y') }}
{# Add empty cells for first row of month #} {% set dayWeekday = day.weekday %} {% if dayWeekday > 1 %} {% for i in 1..dayWeekday-1 %}
{% endfor %} {% endif %} {% endif %} {# Check if week changed #} {% if currentWeek != day.weekNumber %} {% set currentWeek = day.weekNumber %} {% if day.weekday > 1 and not loop.first and currentMonth == day.date|date('F Y') %} {# If it's not the first day overall and not the first day of a month, but it's the first day of a week #} {% for i in 1..day.weekday-1 %}
{% endfor %} {% endif %} {% endif %} {# Render the day #}
{{ day.date|date('d.m.Y') }}
{% if day.isFtk %}
FTK
{% endif %} {% if day.isUrlaub %}
Urlaub
{% endif %}
{# After the last day of a month, fill remaining days in the week #} {% set nextDay = days[loop.index] is defined ? days[loop.index] : null %} {% if nextDay and nextDay.date|date('F Y') != day.date|date('F Y') %} {% if day.weekday < 7 %} {% for i in day.weekday+1..7 %}
{% endfor %} {% endif %} {% endif %} {# After the very last day, fill remaining days in the week #} {% if loop.last and day.weekday < 7 %} {% for i in day.weekday+1..7 %}
{% endfor %} {% endif %} {% endfor %}