ICS Calendar

ICS Calendar
  • Features
    • ICS Calendar Pro
    • Feature Comparison
    • Sample Calendars
    • Preview Your Calendar
    • More WordPress Plugins
  • Help
    • User Guide
      • Getting Started
      • General WordPress Settings
      • ICS Calendar Settings
      • Shortcode Overview
      • Shortcode Reference
      • FAQs and Tips
      • CSS Guide
      • Developer Resources
      • GDPR
    • Pro Documentation
      • Calendar Builder
      • ICS Events
      • Manual Calendar Setup
      • Admin Utilities and Settings
      • Customizer
      • Block Editor
      • Parameters Reference
    • Shortcode Builder
    • Support Request Form
    • Translation Suggestions
  • Blog
  • Download
  • Buy Now
  • Cart
  • My Account
Search
More...

One of the biggest challenges of developing a calendar plugin: date-specific bugs

September 5, 2023

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

Category: Bug Squashing

Categories

  • Uncategorized
  • New Features
  • Bug Squashing
  • Just for Fun
  • Web Design & Development
  • Translation
  • Deep Dives

Recent Posts

  • ICS Calendar Pro 5.10.0 and ICS Calendar 11.5.9 updates April 24, 2025
  • Big improvements to ICS Events in versions 5.9.0 and 5.9.1 February 26, 2025
  • Happy Holidays from Room 34! December 8, 2024
  • Update to version 5.6.1.1 ASAP to resolve possible database performance issues introduced in 5.6.0 November 14, 2024
  • ICS Calendar Block is officially deprecated in version 5.6, will be removed in version 6.0 November 7, 2024

Related Links

  • Room 34 Creative Services
    Developer of ICS Calendar
  • Underdog of Perfection
    Room 34’s general blog
  • More Plugins by Room 34
    Available in the WordPress Plugin Directory

Room 34 Creative Services, LLC

  • Facebook
  • YouTube
  • Bandcamp
  • Room 34 Creative Services, LLC
  • Minneapolis, Minnesota 55406 USA
  • info@icscalendar.com
  • More WordPress Plugins
  • Privacy Policy
  • Terms & Conditions

Copyright © 2025 Room 34 Creative Services, LLC. All rights reserved.
"ICS Calendar", "ICS Calendar Pro", "ICS Events", the ICS Calendar logo and ICS icon are trademarks of Room 34 Creative Services, LLC.

https://icscalendar.com/one-of-the-biggest-challenges-of-developing-a-calendar-plugin-date-specific-bugs

This website uses cookies solely for necessary functions, such as accessing your account orders and license details. Accept to continue or find out more in our Privacy Policy.

Accept & Continue