返回日历数据
function returnDate(dateYear,dateMonth){
function is_leap(year) {//判断是否为闰年
return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0));
};
function is_Month(Month){//判断月份大小并返回当月天数
var dateindex = 31;if(Month % 2 == 0){dateindex = 30;if(Month == 2){(is_leap(dateYear))?dateindex = 29:dateindex = 28;};};if(Month >= 8){(Month % 2 == 0)?dateindex = 31:dateindex = 30;};return dateindex;
};
var dateDay = new Date(dateYear,dateMonth-1,1).getDay(),//星期
dateindex = is_Month(dateMonth),
DayData = new Array(42),
newDayAll = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],
newDayAllIndex = 0;
for(var i = 0 ; i < DayData.length ; i++){
if(i % 7 == 0){
newDayAllIndex = 0;
}else{
newDayAllIndex ++;
};
DayData[i] = {
week:newDayAllIndex,
name:newDayAll[newDayAllIndex],
Explain:"说明:getDateIdex 参数为当月天数;dateDayIndex该参数是指当月的1号的索引值为dateDayIndex,即"+dateDay,
dateDayIndex:dateDay,
getDateIdex:is_Month(dateMonth)
};
if(i >= dateDay && i < dateindex+dateDay){
DayData[i].day = i-dateDay+1;
}else if(i < dateDay){
DayData[i].day = is_Month(dateMonth-1)-dateDay+i+1;
switch (dateindex){
case 30:
DayData[i].day = is_Month(dateMonth-1)-dateDay+i+1;
break;
case 31:
DayData[i].day = is_Month(dateMonth)-dateDay+i;
if(dateMonth == 8 || dateMonth == 3){
DayData[i].day = is_Month(dateMonth-1)+1-dateDay+i;
};
if(dateMonth == 1){
DayData[i].day = is_Month(12)+1-dateDay+i;
};
break;
};
}else{
DayData[i].day = i-dateindex-dateDay+1;
};
};
return DayData;
};