try it:
Date.prototype.isLeapYear = function(year) {
if (year == null) { year = this.getFullYear() }
return (year < 1601 && year % 4 == 0) ||
(year % 400 == 0 && year % 100 != 0) ||
year % 4 == 0 ? true : false;
}
usage:
t = new Date();
trace(t.isLeapYear(2004)); // true
trace(t.isLeapYear()); // false (2002)
msg2 {
orangechicken[+],
posted: 10.14.02 6a•-,
top [^]
}
===============================================
No MSA, your logic is flawed my friend.
Here is the REAL WORKING leap year prototype is:
You see, you have to check if the year is divisible by 4 and NOT 100, or the year is divisible by 400.
You had divisible by 4 passing through (and you were checking if the year was divisible by 400 and not 100 ... which would never be true of course)
-chicken
msg3 {
Madokan[+],
posted: 03.02.04 8a•-,
top [^]
}
Have fun!
msg4 {
alfgear[+],
posted: 11.26.04 2a•-,
top [^]
}
Madokan, your code is not working went come to year 2000!!
msg5 {
Madokan[+],
posted: 01.09.05 3a•01.09.05 7a,
top [^]
}
Hi alfgear - getLeapYear works fine 2000 was a leapyear! :)