{% apply trim %}
    {% set all_occurrences = occurrences %}

    {% set beginTimes = all_occurrences|map(o => o.begin|date('Hi')) %}
    {% set endTimes = all_occurrences|map(o => o.end|date('Hi')) %}
    {% set sameBeginTime = beginTimes|reduce((times, time) => time in times ? times : times|merge([time]), [])|length == 1 %}
    {% set sameEndTime = endTimes|reduce((times, time) => time in times ? times : times|merge([time]), [])|length == 1 %}

    {% set formatted_dates = [] %}
    {% if short and all_occurrences|length > 1 %}
        {% set formatted_date = component('Cms:OfferDateSingle', {begin: all_occurrences|first.begin, end: all_occurrences|first.end, locale: locale}) %}
        {{ formatted_date|trim ~ ' ' ~ 'offer.furtherDates'|trans({count: all_occurrences|length - 1}, 'cms') }}
    {% else %}
        {% for occurrence in all_occurrences %}
            {% set noTime = sameBeginTime and sameEndTime and not loop.last %}
            {% set formatted_date = component('Cms:OfferDateSingle', {begin: occurrence.begin, end: occurrence.end, noTime: noTime, locale: locale}) %}
            {% set formatted_dates = formatted_dates|merge([formatted_date|trim]) %}
        {% endfor %}

        {{ formatted_dates|join(delimiter) }}
    {% endif %}
{% endapply %}
