Handling Leap Year Problem

I built a time counter which counts time from a specific date. But on 2012, I recognized that something goes wrong. It showed our anniversary one day earlier. After googling it, I read leap years have one additional day and, I had to change place all my code with the code supports leap years. The main coding idea for handling this problem is something like this;

var currYear = this.today.getFullYear();

if ( (currYear % 4 == 0 && currYear % 100 != 0 ) || currYear % 400 == 0 ) {
this.numOfDays = 366;
}



Bir yanıt yazın

(gerekli)