Missing Dates in Calendar Bug Fix
-
I hope this can help someone else and this is a fix you can implement on the next release, because I never like to update 3rd party plugin code directly.
The issue is that events on the 31 of a month that seem to fall on the first or last day of the week, depending on what setting you have for the start of the week in WordPress, don’t show on the calendar. I did some digging and found a bug with a fairly simple fix. I wonder if you are aware of this bug and if you could include this fix in your next release.
The Bug (classes/em-calendar.php:326-327)
When the last day of the month (e.g., January 31) falls at the exact end of a 5-week grid row, $outset is 0. This means $scope_datetime_end is set to midnight (00:00:00) of the 31st — never advanced by any padding days.
In the long_events loop, two timestamp comparisons then fail:
Any event ending on the 31st (even at 11pm) gets its end date clamped to midnight of the 31st.
The while loop then checks event_start (e.g. 9am) <= event_end (midnight) — which is false — so the event is never placed on the 31st at all.
This affects all events (single-day and multi-day alike) when long_events mode is enabled for the calendar.The Fix
Replace the timestamp comparisons with date-string (Y-m-d) comparisons:
Before
if( $event_end->getTimestamp() > $scope_datetime_end->getTimestamp() ) …
while( $event_start->getTimestamp() <= $event_end->getTimestamp() ) …After
if( $event_end->getDate() > $scope_datetime_end->getDate() ) …
while( $event_start->getDate() <= $event_end->getDate() ) …
getDate() returns a “Y-m-d” string, so the comparison is purely date-based and immune to the midnight boundary issue.
You must be logged in to reply to this topic.