My suggestion? Scrap the script and write your own! It's pretty poor, and was clearly written by a pretty bad coder... here's why:
- the array "ar" is dimensioned with 13 items (0-12), but only 12 are used.
- getDays() accepts a month between 0 and 11 (inclusive), not 1-12 like everything else on the planet.
- the leap year function does not perform sufficient checks to correctly determine whether it really IS a leap year or not. It's code like this that caused the Y2K problem... see
here for more, including how leap years ARE calculated.
- there is no error checking (so months <0 or >11 or non-numeric will fail, and silly years will also fail)
I could go on, but those are the worst flaws. I'm tempted to write my own function and present it here, but then that wouldn't help you learn, and the fact that you are cutting & pasting a script suggests that perhaps you
should.
The information above (including the link) should be enough to allow you to develop your own script, and it's a excellent little problem to use as a learning experience so give it a go! If you get stuck, post what you've got so far...