百度用到的Js日历 大家可以看看
而且日历功能很强大,带有节日、农历等,运行看效果就明白了,相信不会让您失望的。
百度的Js日历,值得一看
body,td,.p1,.p2,.i{font-family:arial} body{margin:6px 0 0 0;background-color:#fff;color:#000;} table{border:0} #cal{width:434px;border:1px solid #c3d9ff;font-size:12px;margin:8px 0 0 15px} #cal #top{height:29px;line-height:29px;background:#e7eef8;color:#003784;padding-left:70px} #cal #top select{font-size:12px} #cal #top input{padding:0} #cal ul#wk{margin:0;padding:0;height:25px} #cal ul#wk li{float:left;width:60px;text-align:center;line-height:25px;list-style:none} #cal ul#wk li b{font-weight:normal;color:#c60b02} #cal #cm{clear:left;border-top:1px solid #ddd;border-bottom:1px dotted #ddd;position:relative} #cal #cm .cell{position:absolute;width:42px;height:36px;text-align:center;margin:0 0 0 9px} #cal #cm .cell .so{font:bold 16px arial;} #cal #bm{text-align:right;height:24px;line-height:24px;padding:0 13px 0 0} #cal #bm a{color:7977ce} #cal #fd{display:none;position:absolute;border:1px solid #dddddf;background:#feffcd;padding:10px;line-height:21px;width:150px} #cal #fd b{font-weight:normal;color:#c60a00} #cal #top{padding-top:4px} 公元 年 月 农历年 [ 年 ]
|
8;h>>=1){
j+=(P[k-1900]&h)?1:0
} return(j+b(k))
} function a(h){
return(K.charAt(h%10)+J.charAt(h%12))
} function b(h){
if(g(h)){
return((P[h-1900]&65536)?30:29)
} else{
return(0)
}
} function g(h){
return(P[h-1900]&15)
} function e(i,h){
return((P[i-1900]&(65536>>h))?30:29)
} function C(m){
var k,j=0,h=0;
var l=new Date(1900,0,31);
var n=(m-l)/86400000;
this.dayCyl=n+40;
this.monCyl=14;
for(k=1900;k0;k++){
h=d(k);
n-=h;
this.monCyl+=12
} if(n0;k++){
if(j>0&&k==(j+1)&&this.isLeap==false){
--k;
this.isLeap=true;
h=b(this.year)
} else{
h=e(this.year,k)
} if(this.isLeap==true&&k==(j+1)){
this.isLeap=false
} n-=h;
if(this.isLeap==false){
this.monCyl++
}
} if(n==0&&j>0&&k==j+1){
if(this.isLeap){
this.isLeap=false
} else{
this.isLeap=true;
--k;
--this.monCyl
}
} if(nparseInt(RegExp.$1))?this.restDays:parseInt(RegExp.$1);
this.lunarFestival=this.lunarFestival.replace(/\*\d/,"")
}
} if(this.lunarMonth==12&&this.lunarDate==e(this.lunarYear,12)){
this.lunarFestival=T["0100"];
this.restDays=1
} this.showInLunar=(this.lunarFestival=="")?this.showInLunar:this.lunarFestival;
this.showInLunar=(this.showInLunar.length>4)?this.showInLunar.substr(0,2)+"...":this.showInLunar
} var Q=(function(){
var X={
} ;
X.lines=0;
X.dateArray=new Array(42);
function Y(a){
return(((a%4===0)&&(a%100!==0))||(a%400===0))
} function G(a,b){
return[31,(Y(a)?29:28),31,30,31,30,31,31,30,31,30,31][b]
} function C(a,b){
a.setDate(a.getDate()+b);
return a
} function Z(a){
var f=0;
var c=new U(new Date(a.solarYear,a.solarMonth-1,1));
var d=(c.solarWeekDay-1==-1)?6:c.solarWeekDay-1;
X.lines=Math.ceil((d+G(a.solarYear,a.solarMonth-1))/7);
for(var e=0;e0){
c.isRest=true
} if(d-->0||c.solarMonth!=a.solarMonth){
X.dateArray[e]=null;
continue
} var b=new U(new Date());
if(c.solarYear==b.solarYear&&c.solarMonth==b.solarMonth&&c.solarDate==b.solarDate){
c.isToday=true
} X.dateArray[e]=c;
c=new U(C(c.date,1));
f--
}
} return{
init:function(a){
Z(a)
} ,getJson:function(){
return X
}
}
} )();
var W=(function(){
var C=M("top").getElementsByTagName("SELECT")[0];
var X=M("top").getElementsByTagName("SELECT")[1];
var G=M("top").getElementsByTagName("SPAN")[0];
var c=M("top").getElementsByTagName("SPAN")[1];
var Y=M("top").getElementsByTagName("INPUT")[0];
function a(g){
G.innerHTML=g.ganzhiYear;
c.innerHTML=g.shengxiao
} function b(g){
C[g.solarYear-1901].selected=true;
X[g.solarMonth-1].selected=true
} function f(){
var j=C.value;
var g=X.value;
var i=new U(new Date(j,g-1,1));
Q.init(i);
N.draw();
if(this==C){
i=new U(new Date(j,3,1));
G.innerHTML=i.ganzhiYear;
c.innerHTML=i.shengxiao
} var h=new U(new Date());
Y.style.visibility=(j==h.solarYear&&g==h.solarMonth)?"hidden":"visible"
} function Z(){
var g=new U(new Date());
a(g);
b(g);
Q.init(g);
N.draw();
Y.style.visibility="hidden"
} function d(k,g){
for(var j=1901;j4||c[a].isRest)?"#c60b02":"#313131";
b.innerHTML=c[a].solarDate;
X.appendChild(b);
var Y=R("DIV");
Y.style.color="#666";
Y.innerHTML=c[a].showInLunar;
X.appendChild(Y);
X.onmouseover=(function(d){
return function(f){
F.show({
dateIndex:d,cell:this
} )
}
} )(a);
X.onmouseout=function(){
F.hide()
} ;
M("cm").appendChild(X)
} var G=R("DIV");
G.id="fd";
M("cm").appendChild(G);
F.init(G)
} return{
draw:function(G){
C(G)
}
}
} )();
var F=(function(){
var C;
function Y(e,c){
if(arguments.length>1){
var b=/([.*+?^=!:${}()|[\]\/\\])/g,Z="{".replace(b,"\\$1"),d="}".replace(b,"\\$1");
var a=new RegExp("#"+Z+"([^"+Z+d+"]+)"+d,"g");
if(typeof (c)=="object"){
return e.replace(a,function(f,h){
var g=c[h];
return typeof (g)=="undefined"?"":g
} )
}
} return e
} function G(b){
var a=Q.getJson().dateArray[b.dateIndex];
var Z=b.cell;
var c="#{solarYear} 年 #{solarMonth} 月 #{solarDate} 日 #{solarWeekDayInChinese}";
c+="
农历 #{lunarMonthInChinese}月#{lunarDateInChinese}";
c+="
#{ganzhiYear}年 #{ganzhiMonth}月 #{ganzhiDate}日";
if(a.solarFestival!=""||a.lunarFestival!=""||a.jieqi!=""){
c+="
#{lunarFestival} #{solarFestival} #{jieqi}"
} C.innerHTML=Y(c,a);
C.style.top=Z.offsetTop+Z.offsetHeight-5+"px";
C.style.left=Z.offsetLeft+Z.offsetWidth-5+"px";
C.style.display="block"
} function X(){
C.style.display="none"
} return{
show:function(Z){
G(Z)
} ,hide:function(){
X()
} ,init:function(Z){
C=Z
}
}
} )();
var A=new U(new Date());
if(S){
window.attachEvent("onload",function(){
W.reset(A)
} )
} W.init(A);
Q.init(A);
N.draw();
} )();
//-->
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]