根據(jù)一個(gè)數(shù)字日期,判斷這個(gè)日期是這一年的第幾天户敬,代碼如下:
? ? <script>
????????var?year?=parseInt(prompt('年'));
// 【注】prompt()輸入的為字符串落剪,需要轉(zhuǎn)換為數(shù)字;
????????var?month?=?parseInt(prompt('月'));
????????var?day?=?parseInt(prompt('日'));
????????var?date?=?0;
????????switch(month){
????????????case?12:date?+=?30;
????????????case?11:date?+=?31;
????????????case?10:date?+=?30;
????????????case?9:date?+=?31;
????????????case?8:date?+=?31;
????????????case?7:date?+=?30;
????????????case?6:date?+=?31;
????????????case?5:date?+=?30;
????????????case?4:date?+=?31;
????????????case?3:
????????????if(year?%?4?==?0&&year?%?100?!=?0||year?%?400?==?0){
????????????????date?+=?29;
????????????}else{
????????????????date?+=28;
????????????}???????????????
????????????case?2:date?+=?31;
????????????case?1:date?+=?day;
????????????//?if(year?%?4?==?0&&year?%?100?!=?0||year?%?400?==?0){
????????????//???date=day;
????????????//??alert(year+"年"+month+"月"+day+"天是該年的第"+date+"天");????????????????
????????}???????????
????????????alert(year+"年"+month+"月"+day+"天是該年的第"+date+"天");
????</script>