function GetNumOfTheDate2(sYear,sMonth,sDay){
var days = 0,febDays=28;
if(IsRunYear(sYear)){
febDays=29;
}
switch(sMonth){
case 12:days=days+30;
case 11:days=days+31;
case 10:days=days+30;
case 9:days=days+31;
case 8:days=days+31;
case 7:days=days+30;
case 6:days=days+31;
case 5:days=days+30;
case 4:days=days+31;
case 3:days=days+febDays;
case 2:days=days+31;
case 1:days=days+date;
}
}
function IsRunYear(sYear){//判断是否闰年
var IsRun=false;
((sYear%4==0 && sYear%100!=0)||(sYear%400==0))?IsRun=true:IsRun=false;
return IsRun;
}
//不需要用switch
var str = prompt("请输入(年-月-日)","2018-7-25");
var a = str.split(/\D/);
var d1 = new Date(a[0],0,0).getTime();
var d2 = new Date(a[0],a[1]-1,a[2]).getTime();
var n = Math.floor((d2-d1)/(1000*60*60*24));
alert(str+"日期是该年的第"+n+"天");