<div class="calendar-header">
{% if monthBefore is not empty %}
<a
class="calendar-header-btn calendar-btn-month-prev" href="#"
data-date-year="{{ monthBefore|date('Y') }}"
data-date-month="{{ monthBefore|date('n') }}"
data-date-day="1"
>
<em class="calendar-icon calendar-icon-prev" aria-hidden="true"></em>
<span class="sr-only">Navigate to previous month</span>
</a>
{% endif %}
<div class="calendar-header-title">{{ monthStart|date('F') }} {{ monthStart|date('Y') }}</div>
{% if monthAfter is not empty %}
<a
class="calendar-header-btn calendar-btn-month-next" href="#"
data-date-year="{{ monthAfter|date('Y') }}"
data-date-month="{{ monthAfter|date('n') }}"
data-date-day="1"
>
<em class="calendar-icon calendar-icon-next" aria-hidden="true"></em>
<span class="sr-only">Navigate to next month</span>
</a>
{% endif %}
</div>
<div class="calendar-table">
<ul class="calendar-table-head">
<li class="calendar-table-day calendar-table-day-empty">S</li>
<li class="calendar-table-day calendar-table-day-empty">M</li>
<li class="calendar-table-day calendar-table-day-empty">T</li>
<li class="calendar-table-day calendar-table-day-empty">W</li>
<li class="calendar-table-day calendar-table-day-empty">T</li>
<li class="calendar-table-day calendar-table-day-empty">F</li>
<li class="calendar-table-day calendar-table-day-empty">S</li>
</ul>
<ul class="calendar-table-row">
{% set week = null %}
{% for date in dates %}
{% if week is empty %}
{% set week = date.week %}
{% endif %}
{% if week != date.week %}
{% set week = date.week %}
</ul>
<ul class="calendar-table-row">
{% endif %}
<li
class="
calendar-table-day
{% if date.pm is same as(true) %}calendar-table-day-pm{% endif %}
{% if date.nm is same as(true) %}calendar-table-day-nm{% endif %}
"
data-date-year="{{ date.date|date('Y') }}"
data-date-month="{{ date.date|date('n') }}"
data-date-day="{{ date.date|date('j') }}"
>
<span>
{% if date.date >= monthStart and date.date <= monthEnd and date.events|length > 0 %}
<a href="#">
{% endif %}
<span>{{ date.date|date('j') }}</span>
{% if date.date >= monthStart and date.date <= monthEnd and date.events|length > 0 %}
</a>
{% endif %}
</span>
</li>
{% if date.date|date('Y-m-d') == today|date('Y-m-d') %}
{% set events = date.events %}
{% endif %}
{% endfor %}
</ul>
</div>