I must be in a bit of a ranting mode this week, but I couldn’t get past this one.
So I’m implementing a web based calendar for a client. I decide to use a fairly normal jQuery plugin called FullCalendar. For the most part, it works as you’d expect.
Query a list of events. Render a calendar, with those events displayed.
My client’s requirement stated that when the calendar loads, show the current month. But every time it loads, we actually were showing the next month into the future. March became April.
Tracing, breakpoints, quickwatches. All the date values look correct. But the default month never matched the current month.
Then I figured I would RTFM and to my amazement, I found this:
IMPORTANT: The value is 0 based, meaning January=0, February=1, etc.
However, the year parameter is not zero-based, meaning 2013 == 2013.
If I had to guess, the month value might be handled in an array. And most arrays are zero-based. Fine. But when you alter the basic expectation of what a value is and how it behaves, you fail your user. You waste their time. You’ve wasted my time and my client’s money.
Writing code that is consumed by others requires that you think about the consumer and making their life easier, not take shortcuts to make your life easier.
At least I can appreciate that this peculiarity was included in the otherwise admirable documentation. And I definitely appreciate the overall functionality of this plugin. But I don’t appreciate creating an exception when one doesn’t need to. It smells of laziness, and as coders we can do better.