发布网友 发布时间:2022-04-24 11:33
共1个回答
热心网友 时间:2022-04-24 21:01
<html>
<head>
</head>
<body>
<script type="text/javascript">
var str0="2013-02";
var str1="2013-03";
var str2="2012-02";
var str3="1900-02";
function getDate(dateStr){
var arr=new Array();
var year=dateStr.split("-")[0];
var month=dateStr.split("-")[1];
arr.push(dateStr+"-10");
arr.push(dateStr+"-20");
if(parseInt(month)!=2){
arr.push(dateStr+"-"+getLastDay(month));
}else{
arr.push(dateStr+"-"+getFreLastDay(year));
}
return arr;
}
function getLastDay(month){
month=parseInt(month);
switch(month){
case 1:
return 31;
case 3:
return 31;
case 4:
return 31;
case 5:
return 31;
case 6:
return 31;
case 7:
return 31;
case 8:
return 31;
case 9:
return 30;
case 10:
return 31;
case 11:
return 30;
case 12:
return 31;
}
}
function getFreLastDay(year){
year=parseInt(year);
if((year%4==0&&year%100!=0)||year%400==0){
return 29;
}
return 28;
}
var arr0=getDate(str0);
for(var i=0;i<arr0.length;i++){
alert(arr0[i]);
}
var arr1=getDate(str1);
for(var i=0;i<arr1.length;i++){
alert(arr1[i]);
}
var arr2=getDate(str2);
for(var i=0;i<arr2.length;i++){
alert(arr2[i]);
}
var arr3=getDate(str3);
for(var i=0;i<arr3.length;i++){
alert(arr3[i]);
}
</script>
</body>
</html>