I know I’m probably missing something obvious, but I can’t see why this doesn’t work…..
// Constructor
function calendar(id, d){
this.id = id;
this.dateObject = d;
this.write = writeCalendar;
this.month = d.getMonth();
this.date = d.getDate();
this.day = d.getDay();
this.year = d.getFullYear();
[B]this.length = getLength();
this.getFormattedDate = getFormattedDate;
d.setDate(1);
this.firstDay = d.getDay();
d.setDate(this.date);
}
[B]function getLength()
switch(this.month){
case 1:
if ((this.dateObject.getFullYear()%4==0 &&
this.dateObject.getFullYear()%100!=0) ||
this.dateObject.getFullYear()%400==0)
return 29; // leap year
else
return 28;
case 3:
return 30;
case 5:
return 30;
case 8:
return 30;
case 10:
return 30;
default:
return 31;
}
}
My getLength function is returning 31 for April and I can’t figure out why this doesn’t work. 0 = Jan, so 3 should = April….Can anyone tell me what I’m doing wrong here ??? Thanks. ?