Is this what you're looking for?
function incrementClock(){
clock.seconds++;
if (clock.seconds >=60) {
clock.seconds = 0;
clock.minutes++;
if (clock.minutes >=60) {
clock.minutes = 0;
clock.hours++;
if (clock.hours >=24) {
clock.hours = 0;
clock.days++;
var months = [31,((clock.year%4==0)&&((clock.year%100!=0)||(clock.year%400==0)))?29:28,31,30,31,30,31,31,30,31,30,31];
if (clock.days>months[clock.month-1]){
clock.days = 0;
clock.months++;
}
}
}
}
}
This line:
var months = [31,((clock.year%4==0)&&((clock.year%100!=0)||(clock.year%400==0)))?29:28,31,30,31,30,31,31,30,31,30,31];
creates an array of the months and the days in each month. Thus it is easy to determine the amount of days per month like so:
days_in_jan = months[0]
days_in_feb = months[1]
...
days_in_dec = months[11]