求高手改写js代码

<SCRIPTlanguage=javascript><!--calendar=newDate();day=calendar.getDay();month=calenda... <SCRIPT language=javascript>
<!--
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year< 100) year = 1900 + year;
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("日", "一", "二", "三", "四", "五", "六");
var monthname =
new Array ("1","2","3","4","5","6","7","8","9","10","11","12" );
document.write("今天是:" + "<font color=0000FF>" + year+ "</font>" +"年");
document.write("<font color=0000FF>" + monthname[month]+ "</font>" +"月");
document.write("<font color=0000FF>" + date + "</font>" + "日");
document.write("星期" + "<font color=0000FF>" + dayname[day] +"</font>" + " ");

// January(1月份节日,以下同。)
if ((month == 0) && (date == 1)) document.write("元旦");
if ((month == 0) && (date == 10)) document.write("我的生日");
if ((month == 4) && (date == 1)) document.write("国际劳动节");
if ((month == 4) && (date == 4)) document.write("青年节");
if ((month == 5) && (date == 1)) document.write("国际儿童节");
if ((month == 11) && (date == 25)) document.write("圣诞节");
if ((month == 11) && (date == 8)) document.write("<font color=FF0000>圣诞节</font>");

//-->
</SCRIPT>

以上是显示当天的日期信息,求人再加段js代码把对应的节日的倒计时给显示出来,
当然是下一个节日了,当天的节日就不用倒记时了!

真郁闷,1楼是来拿分的吧,2楼是来骗个ip的?
展开
 我来答
xep0825
推荐于2016-03-15 · TA获得超过623个赞
知道小有建树答主
回答量:379
采纳率:100%
帮助的人:513万
展开全部
<SCRIPT language=javascript>
<!--
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year< 100) year = 1900 + year;
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("日", "一", "二", "三", "四", "五", "六");
var monthname =
new Array ("1","2","3","4","5","6","7","8","9","10","11","12" );
document.write("今天是:" + "<font color=0000FF>" + year+ "</font>" +"年");
document.write("<font color=0000FF>" + monthname[month]+ "</font>" +"月");
document.write("<font color=0000FF>" + date + "</font>" + "日");
document.write("星期" + "<font color=0000FF>" + dayname[day] +"</font><br/>" + " ");
document.write(getNextFestival());

// January(1月份节日,以下同。)
if ((month == 0) && (date == 1)) document.write("元旦");
if ((month == 0) && (date == 10)) document.write("我的生日");
if ((month == 4) && (date == 1)) document.write("国际劳动节");
if ((month == 4) && (date == 4)) document.write("青年节");
if ((month == 5) && (date == 1)) document.write("国际儿童节");
if ((month == 11) && (date == 25)) document.write("圣诞节");

function getNextFestival()
{
var arrFestival = [[0, 1, "元旦"], [0, 10, "我的生日"], [4, 1, "国际劳动节"], [4, 4, "青年节"], [5, 1, "国际儿童节"], [11, 25, "圣诞节"], [12, 1, "元旦"]];
var index = 0;
for(var m=0; m<arrFestival.length; m++)
{
index = m;
if(month<arrFestival[m][0] || (month==arrFestival[m][0] && date<arrFestival[m][1]))
{
break;
}
}
var calendarF = new Date();
calendarF.setFullYear(year, arrFestival[index][0], arrFestival[index][1]);
var days = parseInt((calendarF - calendar) / 3600000 / 24, 10);
return "距 " + arrFestival[index][2] + " 还有 " + days + " 天";
}

//-->
</SCRIPT>
snloop
2009-12-14 · 超过17用户采纳过TA的回答
知道答主
回答量:55
采纳率:0%
帮助的人:39.8万
展开全部
你那个时间日期太罗嗦,我改成GetTime() 函数了..
HoliDay()函数为节日倒计时...

<script>
function GetTime(){
document.write("<span id='CNlock'> </span>");
var Obj=document.getElementById('CNlock');
var $SetTime=function(){
var Daty=new Date();
var year=Daty.getYear();
var month=Daty.getMonth()+1;
var day=Daty.getDate();
var hours=Daty.getHours();
var minutes=Daty.getMinutes();
var seconds=Daty.getSeconds();
if(minutes<=9){minutes="0"+minutes;}
if(seconds<=9){seconds="0"+seconds;}
Obj.innerHTML=year+'年'+month+'月'+day+'日 '+hours+':'+minutes+':<span style="color:#F00">'+seconds+'</span>';
}
$SetTime();setInterval($SetTime,1000);
}
GetTime(); //当前时间
function HoliDay(){
document.write("<Div Id='Gala'> </Div>");
var FesTival={ //自定节日名称和日期
'元旦' :'0/1' ,
'我的生日' :'0/10',
'国际劳动节':'4/1' ,
'青年节' :'4/4' ,
'国际儿童节':'4/1' ,
'圣诞节' :'4/1' //最后一个不要加','号
};
Day(FesTival,'Gala');
}
function Day(A_rray,ObjId){
var $=function $(Obj){return document.getElementById(Obj);}
var Obj_Str='';var Obj=$(ObjId);
var Day_Diff=function Day_Diff(Day_O,Day_T){
Day_O=new Date(Day_O);
Day_T=new Date(Day_T);
return Math.floor((Day_T.getTime()-Day_O.getTime())/(1000 * 60 * 60 * 24));
}
var Time=new Date();
for(A in A_rray){
var Time_O=Time.getYear()+'/'+Time.getMonth()+'/'+Time.getDate()
var M_Num=parseInt(A_rray[A].split('/')[0]);
var Y_Num=Time.getYear();
if(M_Num<Time.getMonth()){Y_Num++;}
var Time_T=Y_Num+'/'+A_rray[A]
Obj_Str=Obj_Str+A+":<span style='color:#F00'>倒计时</span>:<span style='color:#008000;'>"+Day_Diff(Time_O,Time_T)+"</span><span style='color:#666;'>天</span><br>";
}
Obj.innerHTML=Obj_Str;
}
HoliDay(); // 节日倒计时
</script>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
dony_fox
2009-12-09 · 超过31用户采纳过TA的回答
知道答主
回答量:137
采纳率:0%
帮助的人:96.6万
展开全部
对应的节日是指当天的节日 还是距下一个节日的时间?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式