<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<title>百度的Js日历 (含节日,农历)</title>
<style type="text/css">
body,td,.p1,.p2,.i {
font-family: arial
}
body {
margin: 6px 0 0 0;
background-color:#F0FBF4;
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: #ffffff;
padding-left: 70px;
background-color:#000080;
}
#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
}
</style>
<!--[if IE]>
<style>
#cal #top{padding-top:4px}
#cal #top input{width:65px}
#cal #fd{width:170px}
</style>
<![endif]-->
<body>
<table cellpadding="0" cellspacing="0" id="1" align="center" style="margin-top:100px;">
<tr>
<td>
<div id="cal">
<div id="top">公元 <select>
</select> 年 <select>
</select> 月 农历<span></span>年 [ <span></span>年 ] <input type="button"
value="回到今天" title="点击后跳转回今天" style="padding: 0px"></div>
<ul id="wk">
<li>一</li>
<li>二</li>
<li>三</li>
<li>四</li>
<li>五</li>
<li><b>六</b></li>
<li><b>日</b></li>
</ul>
<div id="cm"></div>
<div id="bm"></div>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
(function() {
var S = navigator.userAgent.indexOf("MSIE") != -1 && !window.opera;
function M(C) {
return document.getElementById(C)
}
function R(C) {
return document.createElement(C)
}
var P = [ 19416, 19168, 42352, 21717, 53856, 55632, 91476, 22176,
39632, 21970, 19168, 42422, 42192, 53840, 119381, 46400, 54944,
44450, 38320, 84343, 18800, 42160, 46261, 27216, 27968, 109396,
11104, 38256, 21234, 18800, 25958, 54432, 59984, 28309, 23248,
11104, 100067, 37600, 116951, 51536, 54432, 120998, 46416,
22176, 107956, 9680, 37584, 53938, 43344, 46423, 27808, 46416,
86869, 19872, 42448, 83315, 21200, 43432, 59728, 27296, 44710,
43856, 19296, 43748, 42352, 21088, 62051, 55632, 23383, 22176,
38608, 19925, 19152, 42192, 54484, 53840, 54616, 46400, 46496,
103846, 38320, 18864, 43380, 42160, 45690, 27216, 27968, 44870,
43872, 38256, 19189, 18800, 25776, 29859, 59984, 27480, 21952,
43872, 38613, 37600, 51552, 55636, 54432, 55888, 30034, 22176,
43959, 9680, 37584, 51893, 43344, 46240, 47780, 44368, 21977,
19360, 42416, 86390, 21168, 43312, 31060, 27296, 44368, 23378,
19296, 42726, 42208, 53856, 60005, 54576, 23200, 30371, 38608,
19415, 19152, 42192, 118966, 53840, 54560, 56645, 46496, 22224,
21938, 18864, 42359, 42160, 43600, 111189, 27936, 44448 ];
var K = "甲乙丙丁戊己庚辛壬癸";
var J = "子丑寅卯辰巳午未申酉戌亥";
var O = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
var L = [ "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满",
"芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降",
"立冬", "小雪", "大雪", "冬至" ];
var D = [ 0, 21208, 43467, 63836, 85337, 107014, 128867, 150921,
173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033,
353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758 ];
var B = "日一二三四五六七八九十";
var H = [ "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊" ];
var E = "初十廿卅";
var V = {
"0101" : "*1元旦节",
"0214" : "情人节",
"0308" : "妇女节",
"0312" : "植树节",
"0315" : "消费者权益日",
"0401" : "愚人节",
"0501" : "*1劳动节",
"0504" : "青年节",
"0601" : "国际儿童节",
"0701" : "流氓蛋生日",
"0910" : "中国教师节",
"1224" : "平安夜",
"1225" : "圣诞节"
};
var T = {
"0101" : "*2春节",
"0115" : "元宵节",
"0505" : "*1端午节",
"0707" : "*1七夕",
"0815" : "*1中秋节",
"0909" : "重阳节",
"1208" : "腊八节",
"0100" : "除夕"
};
function U(Y) {
function c(j, i) {
var h = new Date((31556925974.7 * (j - 1900) + D[i] * 60000)
+ Date.UTC(1900, 0, 6, 2, 5));
return (h.getUTCDate())
}
function d(k) {
var h, j = 348;
for (h = 32768; h > 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; k<2050&&n>0; k++) {
h = d(k);
n -= h;
this.monCyl += 12
}
if (n < 0) {
n += h;
k--;
this.monCyl -= 12
}
this.year = k;
this.yearCyl = k - 1864;
j = g(k);
this.isLeap = false;
for (k = 1; k<13&&n>0; 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 (n < 0) {
n += h;
--k;
--this.monCyl
}
this.month = k;
this.day = n + 1
}
function G(h) {
return h < 10 ? "0" + h : h
}
function f(i, j) {
var h = i;
return j.replace(/dd?d?d?|MM?M?M?|yy?y?y?/g, function(k) {
switch (k) {
case "yyyy":
var l = "000" + h.getFullYear();
return l.substring(l.length - 4);
case "dd":
return G(h.getDate());
case "d":
return h.getDate().toString();
case "MM":
return G((h.getMonth() + 1));
case "M":
return h.getMonth() + 1
}
})
}
function Z(i, h) {
var j;
switch (i, h) {
case 10:
j = "初十";
break;
case 20:
j = "二十";
break;
case 30:
j = "三十";
break;
default:
j = E.charAt(Math.floor(h / 10));
j += B.charAt(h % 10)
}
return (j)
}
this.date = Y;
this.isToday = false;
this.isRestDay = false;
this.solarYear = f(Y, "yyyy");
this.solarMonth = f(Y, "M");
this.solarDate = f(Y, "d");
this.solarWeekDay = Y.getDay();
this.solarWeekDayInChinese = "星期" + B.charAt(this.solarWeekDay);
var X = new C(Y);
this.lunarYear = X.year;
this.shengxiao = O.charAt((this.lunarYear - 4) % 12);
this.lunarMonth = X.month;
this.lunarIsLeapMonth = X.isLeap;
this.lunarMonthInChinese = this.lunarIsLeapMonth ? "闰"
+ H[X.month - 1] : H[X.month - 1];
this.lunarDate = X.day;
this.showInLunar = this.lunarDateInChinese = Z(this.lunarMonth,
this.lunarDate);
if (this.lunarDate == 1) {
this.showInLunar = this.lunarMonthInChinese + "月"
}
this.ganzhiYear = a(X.yearCyl);
this.ganzhiMonth = a(X.monCyl);
this.ganzhiDate = a(X.dayCyl++);
this.jieqi = "";
this.restDays = 0;
if (c(this.solarYear, (this.solarMonth - 1) * 2) == f(Y, "d")) {
this.showInLunar = this.jieqi = L[(this.solarMonth - 1) * 2]
}
if (c(this.solarYear, (this.solarMonth - 1) * 2 + 1) == f(Y, "d")) {
this.showInLunar = this.jieqi = L[(this.solarMonth - 1) * 2 + 1]
}
if (this.showInLunar == "清明") {
this.showInLunar = "清明节";
this.restDays = 1
}
this.solarFestival = V[f(Y, "MM") + f(Y, "dd")];
if (typeof this.solarFestival == "undefined") {
this.solarFestival = ""
} else {
if (/\*(\d)/.test(this.solarFestival)) {
this.restDays = parseInt(RegExp.$1);
this.solarFestival = this.solarFestival.replace(/\*\d/, "")
}
}
this.showInLunar = (this.solarFestival == "") ? this.showInLunar
: this.solarFestival;
this.lunarFestival = T[this.lunarIsLeapMonth ? "00"
: G(this.lunarMonth) + G(this.lunarDate)];
if (typeof this.lunarFestival == "undefined") {
this.lunarFestival = ""
} else {
if (/\*(\d)/.test(this.lunarFestival)) {
this.restDays = (this.restDays > parseInt(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; e < X.dateArray.length; e++) {
if (c.restDays != 0) {
f = c.restDays
}
if (f > 0) {
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; j < 2050; j++) {
var h = R("OPTION");
h.value = j;
h.innerHTML = j;
if (j == k) {
h.selected = "selected"
}
C.appendChild(h)
}
for ( var j = 1; j < 13; j++) {
var h = R("OPTION");
h.value = j;
h.innerHTML = j;
if (j == g) {
h.selected = "selected"
}
X.appendChild(h)
}
C.onchange = f;
X.onchange = f
}
function e(g) {
d(g.solarYear, g.solarMonth);
G.innerHTML = g.ganzhiYear;
c.innerHTML = g.shengxiao;
Y.onclick = Z;
Y.style.visibility = "hidden"
}
return {
init : function(g) {
e(g)
},
reset : function(g) {
b(g)
}
}
})();
var N = (function() {
function C() {
var Z = Q.getJson();
var c = Z.dateArray;
M("cm").style.height = Z.lines * 38 + 2 + "px";
M("cm").innerHTML = "";
for ( var a = 0; a < c.length; a++) {
if (c[a] == null) {
continue
}
var X = R("DIV");
if (c[a].isToday) {
X.style.border = "1px solid #a5b9da";
X.style.background = "#c1d9ff"
}
X.className = "cell";
X.style.left = (a % 7) * 60 + "px";
X.style.top = Math.floor(a / 7) * 38 + 2 + "px";
var b = R("DIV");
b.className = "so";
// http://www.CsrCode.Cn
b.style.color = ((a % 7) > 4 || 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 += "<br><b>农历 #{lunarMonthInChinese}月#{lunarDateInChinese}</b>";
c += "<br>#{ganzhiYear}年 #{ganzhiMonth}月 #{ganzhiDate}日";
if (a.solarFestival != "" || a.lunarFestival != ""
|| a.jieqi != "") {
c += "<br><b>#{lunarFestival} #{solarFestival} #{jieqi}</b>"
}
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();
})();
//-->
</script>
</body>
分享到:
相关推荐
本资源"带阴历和节日的JS日历.rar"提供了一个实现JavaScript日历功能的解决方案,它不仅显示公历日期,还包含阴历以及重要的节日信息,这对于开发具有中国特色的日历应用或网站是非常有用的。 首先,我们要理解这个...
标题中的“日历带农历的控件”指的是一个支持显示公历和农历的JavaScript组件,通常用于网页应用中,帮助用户进行日期相关的操作和展示。这样的控件在各种需要日期管理的场合非常实用,比如在线日程规划、事件预订...
在本项目中,“JS日历带阴历和节日”是一个实用的JavaScript组件,它允许用户在网页上展示一个具有阳历日期、阴历日期以及节日显示功能的日历。这个组件对于那些需要在网站或应用中集成日期选择功能,同时考虑中国...
js日历插件,支持公历、农历的日期选择,在日历中显示公历和农历。
标题中的“javascript 日历 带农历 节气 节日”表明这是一个使用JavaScript编写的日历应用,具有显示农历、节气和节日的功能。在JavaScript编程中,实现这样的功能需要对日期对象有深入理解,同时还需要处理不同历法...
综上所述,创建一个js日历(带阴历和节日)涉及多个方面,包括JavaScript日期处理、农历转换、节日数据处理以及UI交互设计。通过学习和实践这些知识点,开发者可以构建出一个功能强大且用户友好的日历组件。
JavaScript日历是一个常见的网页交互元素,它为用户提供了一个方便的方式来选择日期,常见于表单填写、事件安排等场景。在Web开发中,JavaScript日历组件的实现主要依赖于JavaScript语言和CSS来完成页面布局和样式...
总的来说,"SimpleCalendar.js简单带农历节日的日历插件"是一个集成了前端技术的实践项目,对于学习JavaScript开发、前端设计和日历应用的实现都有很好的参考价值。通过研究这个插件,开发者不仅可以提升编程技能,...
在IT领域,jQuery是一款非常...总之,jQuery日历插件带农历显示是一个实用的工具,它可以增强网站的互动性,并为用户提供额外的信息。通过理解和定制这个插件,开发者可以将它集成到各种项目中,满足用户的多样化需求。
首先,我们要理解这个“带阴历和节日的JS日历”的核心知识点。日历程序通常会涉及到日期对象的处理,JavaScript中的`Date`对象是关键。开发者需要知道如何创建日期实例,获取当前日期,以及进行日期的加减操作。同时...
在给定的标题和描述中,我们聚焦于一个特定的JS应用——日历控件,这是一个方便用户查看日期、农历、节气和节日的小程序。 首先,"JS日历"是指使用JavaScript实现的日历组件,它通常以动态的方式显示公历日期,允许...
SimpleCalendar.js是一款轻量级的日历插件,它特别之处在于不仅提供了标准的阳历功能,还集成了解析和显示农历节日的能力。这款插件旨在为网页应用提供一个简洁、自适应的日期选择解决方案,同时增加了对中国传统...
总结来说,“jQuery日历插件带农历和节假日”是一个实用且功能全面的日历解决方案,它不仅提供基本的日历功能,还能适应具有农历和节假日需求的场景。开发者可以借鉴其设计理念和实现方式,灵活地集成到自己的项目中...
在网页上展示农历日历是许多中国用户需求的功能,JavaScript(简称js)作为一种广泛用于前端开发的脚本语言,能够方便地实现这一功能。本文将详细介绍如何使用JavaScript来实现在网页上展示农历日历,以及如何参考...
然而,根据描述,这个日历组件并不包含农历转换功能,因此它可能仅适用于那些不需要农历显示的场景。 日历组件是网页应用中常见的元素,它通常用于事件管理、日期选择或时间规划。JavaScript使得我们可以动态地在...
这个"带阴历和节日的JS日历"很可能就是基于这样的机制,通过计算公历和阴历之间的转换,实现了双历显示。 在农历方面,中国传统的阴历与公历(阳历)有着显著的不同。阴历根据月相变化来确定月份,而公历则以地球绕...
"日历控件带农历"是指一个特殊设计的日历组件,它不仅显示公历日期,还支持农历日期的查看和选择,这对于中国的用户群体尤其有用,因为中国传统的节日和一些重要的个人事件通常与农历相关。 PowerBuilder是一款强大...
标题中的“小巧的桌面日历,支持农历,可写备忘录”揭示了这款软件的主要功能和特性。这款日历软件设计精巧,占用资源少,适合在桌面上使用,提供用户日常时间管理的需求。其核心特点包括: 1. **桌面日历**:这种...
在这个主题中,我们主要关注的是“js日历 12种js日历”,这显然是一份包含了多种不同实现方式的JavaScript日历组件集合。 1. **日历组件的基本概念** 日历组件是网页中常见的交互元素,它允许用户选择日期,通常...
以上就是关于“各种JS日期控件 还带阴历哦”这一主题的主要知识点。通过这些文件,开发者可以学习到如何在JavaScript中创建一个既支持公历又支持阴历的日期选择控件,从而提升网页应用的用户体验。