Saturday, May 06, 2006

That's not a bug, it's a feature!

I spent about an hour trying to fix a bug in a javascript calendar I was working on... see if you can spot it:

I had dates in MM-YYYY format, that I was trying to parse the month out of. My code (simplified):

function parseMonth(mmyyyy) {
var splitMMYYYY = split('-', mmyyyy);
return parseInt(splitMMYYYY[0]);
}

Now the bug: month was being set to 0 for dates in August and September, both in IE and Firefox. See if you can figure out why.. here's the answer.

If thats not a bad default, I dont know what is.

0 Comments:

Post a Comment

<< Home