Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUGFIX] Get correct year for weekConfig. Use ISO 8601 week-numbering year #1301

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

cdaecke
Copy link
Contributor

@cdaecke cdaecke commented Dec 11, 2024

When browsing the calendar by week, I get the wrong year after calendar week 52. It gives me the year 2024 instead of 2025.

<f:comment>
=== Browse calendar by week ====
<ul class="event-calendar__browser">
<li class="event-calendar__browser-prev">
<f:link.action rel="nofollow" action="calendar" controller="Event" arguments="{overwriteDemand:{week: weekConfig.previous.weeknumber, year: weekConfig.previous.year}}">
&larr; <f:translate key="calendar.week" /> {weekConfig.previous.weeknumber}
</f:link.action>
</li>
<li class="event-calendar__browser-current"><h3><f:translate key="calendar.week" /> {weekConfig.current.weeknumber}</h3></li>
<li class="event-calendar__browser-next">
<f:link.action rel="nofollow" action="calendar" controller="Event" arguments="{overwriteDemand:{week: weekConfig.next.weeknumber, year: weekConfig.next.year}}">
<f:translate key="calendar.week" /> {weekConfig.next.weeknumber} &rarr;
</f:link.action>
</li>
</ul>
<ul class="event-calendar__days">
<f:for each="{weeks.{weekConfig.current.weeknumber}}" as="day">
<f:render partial="Event/CalendarDayItem" arguments="{day: day, settings: settings}"/>
</f:for>
</ul>
</f:comment>

Debugging $firstDayNextWeek gives me 2024-12-30 which results in "2024" for the parameter tx_sfeventmgt_pieventcalendar[overwriteDemand][year]=2024 but it should be 2025.

$firstDayNextWeek = (clone $firstDayOfCurrentWeek)->modify('+1 week');

This pull request addresses this issue, by using the parameter o for formatting the year.

The PHP manual states for the parameter the following:
ISO 8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.

@derhansen
Copy link
Owner

Thanks for finding the issue and for providing a PR to fix it. I will now merge the patch and extend unit tests afterwards, so the issue is covered by tests.

@derhansen derhansen changed the base branch from main to develop December 14, 2024 09:09
@derhansen derhansen self-assigned this Dec 14, 2024
@derhansen derhansen merged commit 1445a80 into derhansen:develop Dec 14, 2024
8 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants