And I’m still mad about it.
This is a bit of silliness that is not fun at all—or, probably, even of much interest to most of you—so, please forgive me if you were looking forward to an ordinary Silly Saturday. This nonsense happened a couple of weeks ago, and I’m still steamed about it.
A little background: I was working on adapting a little open source Javascript program for an online event on which I help out. We had a little game that involved pictures. We wanted it to change to a different set of pictures each day of the event.
I’m kind of a Javascript newbie, but I had managed to create some code that would change picture sets depending on the date. It wasn’t elegant code (since I am a Javascript newbie) and was somewhat constricted to the actual dates of the event.
This meant that prior to the event, no pictures would display. This made it kind of hard to test, and it also made it impossible to demonstrate it to the rest of the committee.
So, I had to figure out a way to change its behavior prior to the start date of the event. And I thought I did. I entered some code that said, basically, if today’s date is before the start date, do these things, and if today’s date is after the start date, do these other things.
I proceeded to test this new code by manually changing the system date on my PC to each day up to and including the start date to see what would happen.
Everything went fine until I hit the start date. At that point, the set of things the program did continued to be the original set of things and not the new set of things that were supposed to start with the event.
I double-checked all my code. Commas, parentheses, brackets, etc. I double-checked my system date. I went back to the Javascript tutorials and references online. I re-thought my logic.
Nothing!
Hours of frustration!
Eventually (shamefully late, actually), I figured out a way for the program to display what it thought the start date I had entered was.
Suddenly, I see that it thought the date entered as (2013, 2, 2) was March 2nd!
March!
Now, I ask you! In all the entirety of the Western World, is there a person alive who would read month 2 as March? Maybe, in those countries where they follow a lunar calendar, and sometimes have thirteen months, someone might have thought of this. Maybe.
But, in my entire life, in every classroom in which I’ve ever sat, January is month 1 and we proceed to count February, March, April, etc. as months 2, 3, 4 and so on.
But not in Javascript.
No!
In Javascript, for no good reason that I have been able to discover, you count months starting from 0. January is month 0 and December is month 11.
If that isn’t the epitome of silliness, I don’t know what is! And, what, I want to know, prevented any of the tutorials I was studying from mentioning that little fact somewhere in the vicinity of their explanations for how to use dates in Javascript?
This whole thing was not only silly, it was damn silly!
On the other hand, I’ll probably never make that mistake again, so I guess there’s that.
