{{- $list := partialCached "tsc/calendar/list" . -}}
{{- $cat := .Get "category" -}}
{{/* warnf "%#v" $cat */}}
{{- $showAge := .Get "showAge" | default false -}}
<table>
    <thead>
        <tr>
            <th>Gruppe</th>
            {{ if $showAge }}<th>Jahrgang</th>{{ end }}
            <th>Tag</th>
            <th>Zeit</th>
            <th>Ort</th>
        </tr>
    </thead>
    <tbody>
        {{ range $list -}}
            {{- $cats := slice .class -}}
            {{- if eq (printf "%T" .class) "[]interface {}" }}{{ $cats = .class }}{{ end -}}
            {{- if not (in $cats $cat) }}{{ continue }}{{ end -}}
            {{/* warnf "%T %#v" .class . */}}
            <tr>
                <td>
                    {{ .title }}{{ with .subtitle }} - {{ . }}{{ end }}
                </td>
                {{ if $showAge }}<td>{{ .age }}</td>{{ end }}
                <td>{{ index site.Data.days .day }}</td>
                <td>
                    {{- $startTimeStr := printf "2025-01-02T%s:00" .start -}}
                    {{- $startTime := time.AsTime $startTimeStr -}}
                    {{- $duration := time.Duration "minute" .duration -}}
                    {{- $endTime := $startTime.Add $duration}}
                    {{/* warnf "Start %s, duration %s, %s" $startTime $duration $endTime */}}
                    {{- $startTime.Format "15:04"}} - {{ $endTime.Format "15:04" }}
                </td>
                <td>{{ .room }}</td>
            </tr>
        {{- end}}
    </tbody>
</table>