It’s a new month! Strangely, as September got underway, I suddenly started to receive a number of support emails concerning a peculiar bug in the (relatively) new “Full” view in ICS Calendar Pro. People were finding that their calendar pages were coming up blank. Switching to “Month” or another view did not cause the same problem.
Once I managed to get some debugging information, I discovered that Full view was bailing out with a fatal error for these users because it was incorrectly calculating the end date for the calendar display. The text string for the date that it was trying to parse was always 20241301
. Well, that’s interesting.
That is clearly supposed to be a date in YYYYMMDD
format. But… uh… there are only 12 months in a year.
Tracing the problem to its source, I discovered a shortcoming in the special calculations I created for determining the end date in Full view, when the “month” tab is turned on. Because of how the FullCalendar.io library handles end dates (exclusive), the calculated date needs to be the first day of the first month after the calendar ends. I was simply handling this by adding 1
to the YYYYMM
portion of the end date.
I was aware that could result in a month value of 13
, but I wasn’t worried, because I was accustomed to the “old school” PHP date functions, which automatically adjust for month and day overruns. You can tell it to use a 13th month, and it will automatically make that January of the next year, or say February 30 and it will know that’s actually March 2 (or March 1 in a leap year).
But here we are using the DateTime
class, rather than the old procedural date functions. And the DateTime
class is much more particular about things like this. Mea culpa.
So then… why did this problem just start occurring? And why isn’t it occurring for everyone? Well… it’s due to a combination of some of the old (pre-version 10.6) default values, along with some of the newer defaults. The default calendar range is now 455 days, or roughly 15-16 months. The month views always round up so that full months are shown, rather than cutting off the events in the middle of a month. The new default also has the calendar starting 3 months in the past, which is why it now has this 15-16 month range, but sites that still use the older settings would just start in the current month. So… these sites would have calendars that are, as of September 1, showing dates through December 2024. Meaning, the calculated “end date” string was… 20241301
. And since Full view was just released in ICS Calendar Pro in the beginning of 2023, no one had ever encountered the miscalculation until September of this year.
ICS Calendar Pro version 4.8.4.3, available today via the WordPress updater, includes a smarter calculation of these end dates to avoid “month 13.” If you’re using ICS Calendar Pro with Full view, I encourage you to update ASAP.
—Scott