solspace / craft-calendar

Calendar for Craft: The most reliable and powerful event management plugin for Craft.
http://docs.solspace.com/craft/calendar/v5
Other
15 stars 14 forks source link

can't change .format to |date in event.selectDatesAsDates #263

Closed outline4 closed 5 months ago

outline4 commented 7 months ago

Describe the bug or issue you're experiencing

When changing .format('') to |date('') it will shift the dates one day.
I need to change it to a date filter in order that the dates will display in german.

Steps to reproduce

In the frontend form I cannot change the date to a localized date:

{% for selectDate in event.selectDatesAsDates %}
    <div class="col-12 col-sm-10 offset-sm-2">
        <input type="hidden" name="calendarEvent[selectDates][]" value="{{ selectDate.toDateTimeString }}" />
        <a href="javascript:;"
             class="remove-select-date"
             style="color: darkred; text-decoration: none; position: relative; top: 1px;">
            <span class="far fa-times-circle"></span>
        </a>
        {{ selectDate.format('D. d. F Y') }}
    </div>
{% endfor %}

If I change {{ selectDate.format('D. d. F Y') }} to {{ selectDate|date('D d. F Y') }} it will shift the dates one day.

How can I achieve what I want to do?

Craft & Plugin Info (please complete the following information):

kjmartens commented 6 months ago

Hi @outline4,

Sorry again for the delays...

This is a limitation that we worked around in other areas where you can change event.startDate.format("l, F j, Y g:ia") to event.startDateLocalized|date("l, F j, Y g:ia") and it will resolve the issue. However, it seems the special Localized version is not available for selectDate.

I've noted this to see if we can get a quick update for this done. 🙂

seandelaney commented 5 months ago

Once PR is approved, merged and new version released, you will be able to do the following:

{% for selectDate in event.selectDatesAsDates %}
   {{ selectDate.format('l, F j, Y') }}
{% endfor %}

{% for selectDate in event.selectDatesAsDatesLocalized %}
   {{ selectDate|date('l, F j, Y') }}
{% endfor %}

{% for exception in event.exceptions %}
   {{ exception.date.format('l, F j, Y') }}
{% endfor %}

{% for exception in event.exceptionsLocalized %}
   {{ exception.date|date('l, F j, Y') }}
{% endfor %}