谁有计算本日“生肖”的算法,别笑我,养家糊口啊 ^_^ (100分)

H

harmer

Unregistered / Unconfirmed
GUEST, unregistred user!
接到一个算命的小单
 
不知道谁研究过周易了:)
 
到下面去下载一个控件吧,有源程序和 DEMO ,支持生肖、天干地支、公历农历等等。
http://61.132.118.165/soft/delphi/Delphi3/moon20.zip
 
过程应该是公历->农历->生肖.
只要知道了农历,生肖就好办了. 所以你去找个农历的控件用一下基本上就OK了...
 
这种算法也有人研究?倒~~~
唉!Delphi用成这样,Borland只有哭泣了!
 
看一看这个网站,上面有历法研究。
http://go8.163.com/msz/_private/05_jqyry/11_19n7rf.html
 
历 法
推算年、月、日的时间长度和它们之间的关系,制定时间序列的法则。由于生产和生活的需要,古代人就希望知道昼夜、月相和季节的变化规律,以及更长时间的计量方法。世界各文明古国很早就开始根据天象观测来制定历法。
  定出年、月、日的长度,是制定历法的主要环节。日的长度是根据太阳每天的视运动定出的;年的月数和日数以及月的日数,有的按天象定出,有的是人为定出的。因按天象确定的年和月所包括的日数不是简单的有理数,例如按季节变化确定的年(即回归年)为 365.24219……日,按月相变化确定的月(即朔望月)为.53059……日,而制定的历法又必须使年的月数和月的日数为整数。因此各国历代制定的历法,侧重点各不相同。大体可分为三类:一类叫阳历,其中年的日数平均约等于回归年,月的日数和年的月数则人为规定,如公历、儒略历等;一类叫阴历,其中月的日数平均约等于朔望月,年的月数则人为规定,如伊斯兰教历、希腊历等;另一类叫阴阳历,其中月的日数平均约等于朔望月,而年的日数又平均约等于回归年,如中国现在还采用的农历、藏历等。
  此外,确定年首、月首、节气以及比年更长的时间单位,也是制定历法的内容。

公 历

公历是现在国际通用的历法,又称格列历,通称阳历。“阳历”又名“太阳历”,系以地球绕行太阳一周为一年,为西方各国所通用,故又名“西历”。我国从辛亥革命后即自民国元年采用阳历,故又名曰“国历”。为与我国旧有之历相对称,故又名曰“新历”。1949年正式规定公元纪年。
公元前身是儒略历,1582年罗马天主教教宗格列高利十三世把全面儒略历1582年10月4日的下一天定为格列历10月15日,中间销去10天。同时修改了儒略历置闰法则。
地球绕太阳一周实际为365.24219天(太阳年),按一年365天计算,每年少0.24219天,每隔4年少0.96876天,每隔400年则少96.876天,因此,400年中需置97个闰年。闰年在2月末加上一天全年366天。这样经过3333年才有一天的误差。
年有三种:地球绕日一周,历三百六十五日六小时九分九秒,谓之“恒星年”;太阳过近地点循黄道东行一周,复过近地点,历三百六十五日六时十三分四十八秒,谓之“近点年”;太阳过春分点,循黄道东行一周,复过春分点,历三百六十五日五小时四十八分四十六秒,谓之“回归年”,亦称“岁实”。
因二分点(春分点秋分点)每年沿黄道向西逆行约五十秒,故回归年较恒星年之时间为短,相差二十分二十三秒,谓之“岁差”。 此三种年之时间不同,欲使每年之节气寒暑不变,故取回归年为制历之年。
对于回归年之时间,有记住之必要,为便于记忆,编一歌诀如下:
地球绕日一周年,要知时间有多少?三六五日加五小,四十八分四六秒。
由一月一日至次年一月一日谓之一年,年长本应与岁实相等,然而一年之日数,必须是整数,不便将奇零之时数计入,故以三百六十五日为一年,每年余五小时四十八分四十六秒至四年约满一日,故每四年增加一日,为闰日,谓之“闰年”。
无闰日这年,谓之“平年”,平年三百六十五日,闰年三百六十六日。 但四年之闰余,仅二十三时十五分四秒,今闰一日,未免过多,超过之四十四分五十六秒,积至二十五闰,为十七时五十八分二十四秒,约合一日之四分之三,故每满百年废一闰,至第四百年又不废。如是每四年置一闰,每四百年减三闰,计超过二小时五十三分二十秒,须八个四百年后,即三千二百年后,始补足此一日之差。



 
这正说明delphi无所不能嘛
delphi能攀上周易
也是他的荣幸
[:D]
 
計算年、月、日的天干地支好像都有公式的,在哪看到過。忘了。
不過我有一個笨辦法,不知是否可行。你只要找一本歷書,
查到某日的天干地支(如2000,1,1),以這一天為基點進行推算。(生肖十二一循環)
天干地支六十循環(從甲子到?亥剛好)不好意思有一個字不會寫!!
子--鼠
亥--豬
 
试试看吧!嘿嘿
<%@ page contentType="text/html;
charset=gb2312" %>
<html>
<head>
<title>网辉万年历</title>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<style>
.todayColor{BACKGROUND-COLOR: cccccc}
.todayColor2{BACKGROUND-COLOR: blue}
</style>
<script language=JavaScript>
<!--
/*****************************************************************************
日期资料
*****************************************************************************/

var lunarInfo=new Array(
0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,
0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,
0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,
0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,
0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,
0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,
0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,
0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0)

var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
var Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪");
var solarTerm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至");
var sTermInfo = new Array(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758);
var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十');
var nStr2 = new Array('初','十','廿','卅',' ');
var EnmonthName = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
var monthName = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");

//国历节日 *表示放假日
var sFtv = new Array(
"0101*元旦",
"0214 情人节",
//"0303 我生日",
"0308 妇女节",
"0312 植树节",
"0315 消费者权益日",
//"0317 St. Patrick's",
"0401 愚人节",
"0501 劳动节",
"0504 青年节",
"0512 护士节",
//"0512 茵生日",
"0601 儿童节",
//"0614 Flag Day",
"0701 建党节 香港回归纪念",
//"0703 炎黄在线诞辰",
//"0718 托普诞辰",
"0801 建军节",
"0808 父亲节",
"0909 毛泽东逝世纪念",
"0910 教师节",
"0928 孔子诞辰",
"1001*国庆节",
"1006 老人节",
"1024 联合国日",
//"1111 Veteran's / Remembrance Day",
"1112 孙中山诞辰纪念",
"1220 澳门回归纪念",
"1225 圣诞节",
"1226 毛泽东诞辰纪念")

//农历节日 *表示放假日
var lFtv = new Array(
"0101*春节",
"0123 我最爱的梅子生日",
"0115 元宵节",
"0505 端午节",
"0707 七夕情人节",
"0715 中元节",
"0815 中秋节",
"0909 重阳节",
"0911 网辉生日",
"1208 腊八节",
"1224 小年",
"0100*除夕")

//某月的第几个星期几
var wFtv = new Array(
//"0131 Martin Luther King Day",
//"0231 President's Day",
"0520 母亲节",
//"0530 Armed Forces Day",
//"0531 Victoria Day",
//"0716 合作节",
//"0730 被奴役国家周",
//"0811 Civic Holiday",
//"0911 Labor Holiday",
//"1021 Columbus Day",
"1144 感恩节")


/*****************************************************************************
日期计算
*****************************************************************************/

//====================================== 传回农历 y年的总天数
function lYearDays(y) {
var i, sum = 348
for(i=0x8000;
i>0x8;
i>>=1) sum += (lunarInfo[y-1900] &amp;
i)? 1: 0
return(sum+leapDays(y))
}

//====================================== 传回农历 y年闰月的天数
function leapDays(y) {
if(leapMonth(y)) return((lunarInfo[y-1900] &amp;
0x10000)? 30: 29)
else
return(0)
}

//====================================== 传回农历 y年闰哪个月 1-12 , 没闰传回 0
function leapMonth(y) {
return(lunarInfo[y-1900] &amp;
0xf)
}

//====================================== 传回农历 y年m月的总天数
function monthDays(y,m) {
return( (lunarInfo[y-1900] &amp;
(0x10000>>m))? 30: 29 )
}

//====================================== 算出农历, 传入日期物件, 传回农历日期物件
// 该物件属性有 .year .month .day .isLeap .yearCyl .dayCyl .monCyl
function Lunar(objDate) {

var i, leap=0, temp=0
var baseDate = new Date(1900,0,31)
var offset = (objDate - baseDate)/86400000

this.dayCyl = offset + 40
this.monCyl = 14

for(i=1900;
i<2050 &amp;&amp;
offset>0;
i++) {
temp = lYearDays(i)
offset -= temp
this.monCyl += 12
}

if(offset<0) {
offset += temp;
i--;
this.monCyl -= 12
}

this.year = i
this.yearCyl = i-1864

leap = leapMonth(i) //闰哪个月
this.isLeap = false

for(i=1;
i<13 &amp;&amp;
offset>0;
i++) {
//闰月
if(leap>0 &amp;&amp;
i==(leap+1) &amp;&amp;
this.isLeap==false)
{ --i;
this.isLeap = true;
temp = leapDays(this.year);
}
else
{ temp = monthDays(this.year, i);
}

//解除闰月
if(this.isLeap==true &amp;&amp;
i==(leap+1)) this.isLeap = false

offset -= temp
if(this.isLeap == false) this.monCyl ++
}

if(offset==0 &amp;&amp;
leap>0 &amp;&amp;
i==leap+1)
if(this.isLeap)
{ this.isLeap = false;
}
else
{ this.isLeap = true;
--i;
--this.monCyl;}

if(offset<0){ offset += temp;
--i;
--this.monCyl;
}

this.month = i
this.day = offset + 1
}

//==============================传回国历 y年某m+1月的天数
function solarDays(y,m) {
if(m==1)
return(((y%4 == 0) &amp;&amp;
(y%100 != 0) || (y%400 == 0))? 29: 28)
else
return(solarMonth[m])
}
//============================== 传入 offset 传回干支, 0=甲子
function cyclical(num) {
return(Gan[num%10]+Zhi[num%12])
}

//============================== 月历属性
function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {

this.isToday = false;
//国历
this.sYear = sYear;
this.sMonth = sMonth;
this.sDay = sDay;
this.week = week;
//农历
this.lYear = lYear;
this.lMonth = lMonth;
this.lDay = lDay;
this.isLeap = isLeap;
//干支
this.cYear = cYear;
this.cMonth = cMonth;
this.cDay = cDay;

this.color = '';

this.lunarFestival = '';
//农历节日
this.solarFestival = '';
//国历节日
this.solarTerms = '';
//节气

}

//===== 某年的第n个节气为几日(从0小寒起算)
function sTerm(y,n) {
var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) )
return(offDate.getUTCDate())
}

//============================== 传回月历物件 (y年,m+1月)
function calendar(y,m) {

var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2
var lDPOS = new Array(3)
var n = 0
var firstLM = 0

sDObj = new Date(y,m,1) //当月一日日期

this.length = solarDays(y,m) //国历当月天数
this.firstWeek = sDObj.getDay() //国历当月1日星期几


for(var i=0;i<this.length;i++) {

if(lD>lX) {
sDObj = new Date(y,m,i+1) //当月一日日期
lDObj = new Lunar(sDObj) //农历
lY = lDObj.year //农历年
lM = lDObj.month //农历月
lD = lDObj.day //农历日
lL = lDObj.isLeap //农历是否闰月
lX = lL? leapDays(lY): monthDays(lY,lM) //农历当月最後一天

if(n==0) firstLM = lM
lDPOS[n++] = i-lD+1
}

//sYear,sMonth,sDay,week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay
this = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],
lY, lM, lD++, lL,
cyclical(lDObj.yearCyl) ,cyclical(lDObj.monCyl), cyclical(lDObj.dayCyl++) )


if((i+this.firstWeek)%7==0) this.color = 'red' //周日颜色
if((i+this.firstWeek)%14==13) this.color = 'red' //周休二日颜色
}

//节气
tmp1=sTerm(y,m*2 )-1
tmp2=sTerm(y,m*2+1)-1
this[tmp1].solarTerms = solarTerm[m*2]
this[tmp2].solarTerms = solarTerm[m*2+1]
if(m==3) this[tmp1].color = 'red' //清明颜色

//国历节日
for(i in sFtv)
if(sFtv.match(/^(/d{2})(/d{2})([/s/*])(.+)$/))
if(Number(RegExp.$1)==(m+1)) {
this[Number(RegExp.$2)-1].solarFestival += RegExp.$4 + ' '
if(RegExp.$3=='*') this[Number(RegExp.$2)-1].color = 'red'
}

//月周节日
for(i in wFtv)
if(wFtv.match(/^(/d{2})(/d)(/d)([/s/*])(.+)$/))
if(Number(RegExp.$1)==(m+1)) {
tmp1=Number(RegExp.$2)
tmp2=Number(RegExp.$3)
this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += RegExp.$5 + ' '
}

//农历节日
for(i in lFtv)
if(lFtv.match(/^(/d{2})(.{2})([/s/*])(.+)$/)) {
tmp1=Number(RegExp.$1)-firstLM
if(tmp1==-11) tmp1=1
if(tmp1 >=0 &amp;&amp;
tmp1<n) {
tmp2 = lDPOS[tmp1] + Number(RegExp.$2) -1
if( tmp2 >= 0 &amp;&amp;
tmp2<this.length) {
this[tmp2].lunarFestival += RegExp.$4 + ' '
if(RegExp.$3=='*') this[tmp2].color = 'red'
}
}
}

//黑色星期五
if((this.firstWeek+12)%7==5)
this[12].solarFestival += '黑色星期五 '

//今日
if(y==tY &amp;&amp;
m==tM) this[tD-1].isToday = true;

}

//====================== 中文日期
function cDay(d){
var s;

switch (d) {
case 10:
s = '初十';
break;
case 20:
s = '二十';
break;
break;
case 30:
s = '三十';
break;
break;
default :
s = nStr2[Math.floor(d/10)];
s += nStr1[d%10];
}
return(s);
}
function convertYear(theYear){
var hanNum = new Array("○","一","二","三","四","五","六","七","八","九");

the1=(theYear%1000)%100%10;
the2=((theYear-the1)/10)%10;
the3=((theYear-the1-the2*10)/100)%10;
the4=(theYear-the1-the2*10-the3*100)/1000;
return hanNum[the4]+hanNum[the3]+hanNum[the2]+hanNum[the1]
}

///////////////////////////////////////////////////////////////////////////////

var cld;

function drawCld(SY,SM) {
var i,sD,s,size;
//alert("SY SM"+SY+" "+SM);
cld = new calendar(SY,SM);

if(SY>1874 &amp;&amp;
SY<1909) yDisplay = '光绪' + (((SY-1874)==1)?'元':SY-1874)
if(SY>1908 &amp;&amp;
SY<1912) yDisplay = '宣统' + (((SY-1908)==1)?'元':SY-1908)
if(SY>1911 &amp;&amp;
SY<1950) yDisplay = '民国' + (((SY-1911)==1)?'元':SY-1911)
//if(SY>1949) yDisplay = '共和国' + (((SY-1949)==1)?'元':SY-1949)

//document.getElementById("GZ").innerHTML = yDisplay +'年 农历' + cyclical(SY-1900+36) + '年 &amp;nbsp;&amp;nbsp;【'+Animals[(SY-4)%12]+'】';

if(SY>1949) yDisplay = ''

do
cument.getElementById("GZ").innerHTML = convertYear(SY)+'年'+monthName[SM]+' '
//+ EnmonthName[SM]
+yDisplay +' 农历' + cyclical(SY-1900+36) + '年 &amp;nbsp;&amp;nbsp;【'+Animals[(SY-4)%12]+'】';

//document.getElementById("YMBG").innerHTML = "&amp;nbsp;" + SY + "<BR>&amp;nbsp;" + monthName[SM];


for(i=0;i<42;i++) {

sObj=document.getElementById("SD"+i);
lObj=document.getElementById("LD"+i);
gObj=document.getElementById("GD"+i);

sObj.className = '';

sD = i - cld.firstWeek;

if(sD>-1 &amp;&amp;
sD<cld.length) { //日期内
sObj.innerHTML = sD+1;

if(cld[sD].isToday){
//sObj.className = 'todayColor';
//今日颜色
//lObj.className = 'todayColor';
gObj.className = 'todayColor';
}
else
{
gObj.className = '';
}

sObj.style.color = cld[sD].color;
//国定假日颜色

if(cld[sD].lDay==1) //显示农历月
lObj.innerHTML = '<b>'+(cld[sD].isLeap?'闰':'') + cld[sD].lMonth + '月' + (monthDays(cld[sD].lYear,cld[sD].lMonth)==29?'小':'大')+'</b>';
else
//显示农历日
lObj.innerHTML = cDay(cld[sD].lDay);

s=cld[sD].lunarFestival;
if(s.length>0) { //农历节日
if(s.length>6) s = s.substr(0, 4)+'…';
s = s.fontcolor('red');
}
else
{ //国历节日
s=cld[sD].solarFestival;
if(s.length>0) {
size = (s.charCodeAt(0)>0 &amp;&amp;
s.charCodeAt(0)<128)?8:4;
if(s.length>size+2) s = s.substr(0, size)+'…';
s = s.fontcolor('blue');
}
else
{ //廿四节气
s=cld[sD].solarTerms;
if(s.length>0) s = s.fontcolor('limegreen');
}
}
if(s.length>0) lObj.innerHTML = s;

}
else
{ //非日期
sObj.innerHTML = '';
lObj.innerHTML = '';
}
}
}

function changeLong()
{
var y,m,ly,lm,id,im,iy,yangy,yangm,deltm,miny,tt;
do
cument.CLD.SY.selectedIndex=document.CLD.D1.selectedIndex;
do
cument.CLD.SM.selectedIndex=document.CLD.D2.selectedIndex;
//alert(document.CLD.SY.selectedIndex+" "+document.CLD.SM.selectedIndex);
yangm=0;yangy=0;
tt=true;
while (tt)
{
yangm=0;yangy=0;
changeCld();
for(i=0;i<42;i++)
{
sD = i - cld.firstWeek;
if(sD>-1 &amp;&amp;
sD<cld.length)
{ //日期内
if ((cld[sD].lMonth==document.CLD.D2.selectedIndex+1)&amp;&amp;(cld[sD].lYear==document.CLD.D1.selectedIndex+1900))
{
yangy=document.CLD.SY.selectedIndex+1900;
yangm=document.CLD.SM.selectedIndex ;
tt=false;
break;
}
}
}
if (!tt) break;

pushBtm('MD');
changeCld();

//alert(document.CLD.SY.selectedIndex+" "+document.CLD.SM.selectedIndex);

for(i=0;i<42;i++)
{
sD = i - cld.firstWeek;
if(sD>-1 &amp;&amp;
sD<cld.length)
{ //日期内
if ((cld[sD].lMonth==document.CLD.D2.selectedIndex+1)&amp;&amp;(cld[sD].lYear==document.CLD.D1.selectedIndex+1900))
{
yangy=document.CLD.SY.selectedIndex+1900;
yangm=document.CLD.SM.selectedIndex ;
tt=false;
break;
}
}
}
break;
}
// alert(yangy+" "+yangm);


//CLD.SY.selectedIndex=yangy;//-1900;
//pushBtm('YU');
//pushBtm('YD');
do
cument.CLD.SM.selectedIndex=yangm;
pushBtm('MD');
pushBtm('MU');



}
//changeLong end

function changeCld() {
var y,m;
y=document.CLD.SY.selectedIndex+1900;
m=document.CLD.SM.selectedIndex;
//alert(y+" "+m);
drawCld(y,m);
}

function pushBtm(K) {
switch (K){
case 'YU' :
if(document.CLD.SY.selectedIndex>0)do
cument.CLD.SY.selectedIndex--;
break;
case 'YD' :
if(document.CLD.SY.selectedIndex<149)do
cument.CLD.SY.selectedIndex++;
break;
case 'MU' :
if(document.CLD.SM.selectedIndex>0) {
do
cument.CLD.SM.selectedIndex--;
}
else
{
do
cument.CLD.SM.selectedIndex=11;
if(document.CLD.SY.selectedIndex>0)do
cument.CLD.SY.selectedIndex--;
}
break;
case 'MD' :
if(document.CLD.SM.selectedIndex<11) {
do
cument.CLD.SM.selectedIndex++;
}
else
{
do
cument.CLD.SM.selectedIndex=0;
if(document.CLD.SY.selectedIndex<149)do
cument.CLD.SY.selectedIndex++;
}
break;
default :
do
cument.CLD.SY.selectedIndex=tY-1900;
do
cument.CLD.SM.selectedIndex=tM;
}
changeCld();
}



var Today = new Date();
var tY = Today.getFullYear();
var tM = Today.getMonth();
var tD = Today.getDate();
//////////////////////////////////////////////////////////////////////////////

var width = "130";
var offsetx = 2;
var offsety = 16;

var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;

var dStyle;
do
cument.onmousemove = mEvn;

//显示详细日期资料
function mOvr(v) {
var s,festival;
// alert(myId);
var sObj=document.getElementById("SD"+v);
var d=sObj.innerHTML-1;
//alert(sObj.innerHTML);

//sYear,sMonth,sDay,week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay

if(sObj.innerHTML!='') {

sObj.style.cursor = 's-resize';

if(cld[d].solarTerms == '' &amp;&amp;
cld[d].solarFestival == '' &amp;&amp;
cld[d].lunarFestival == '')
festival = '';
else
festival = '<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#CCFFCC"><TR><TD>'+
'<FONT COLOR="#000000" STYLE="font-size:9pt;">'+cld[d].solarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD>'+
'</TR></TABLE>';

s= '<TABLE WIDTH="130" BORDER=0 CELLPADDING="2" CELLSPACING=0 BGCOLOR="#000066"><TR><TD>' +
'<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN="right"><FONT COLOR="#ffffff" STYLE="font-size:9pt;">'+
cld[d].sYear+' 年 '+cld[d].sMonth+' 月 '+cld[d].sDay+' 日<br>星期'+cld[d].week+'<br>'+
'<font color="violet">农历'+(cld[d].isLeap?'闰 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日</font><br>'+
'<font color="yellow">'+cld[d].cYear+'年 '+cld[d].cMonth+'月 '+cld[d].cDay + '日</font>'+
'</FONT></TD></TR></TABLE>'+ festival +'</TD></TR></TABLE>';


do
cument.getElementById("detail").innerHTML = s;

if (snow == 0) {
dStyle.left = x+offsetx-(width/2);
dStyle.top = y+offsety;
dStyle.visibility = "visible";
snow = 1;
}
}
}

//清除详细日期资料
function mOut() {
if ( cnt >= 1 ) { sw = 0 }
if ( sw == 0 ) { snow = 0; dStyle.visibility = "hidden";}
else
cnt++;
}

//取得位置
function mEvn(evnt) {
//alert(evnt.x);
//alert(navigator.appName);
if(navigator.appName=="Microsoft Internet Explorer")
{
x=event.x;
y=event.y;
if (document.body.scrollLeft)
{x=event.x+document.body.scrollLeft;
y=event.y+document.body.scrollTop;}
if (snow){
dStyle.left = x+offsetx-(width/2)
dStyle.top = y+offsety
}
}
else
{
x=evnt.layerX;
y=evnt.layerY;
if (pageXOffset)
{x=evnt.layerX+pageXOffset;
y=evnt.layerY+pageYOffset;}
if (snow){
dStyle.left = x+offsetx-(width/2)
dStyle.top = y+offsety
}
}
}

///////////////////////////////////////////////////////////////////////////

function tick() {
var today;
today = new Date();
myMonth=today.getMonth()+1;

myDay=today.getDate();


myHour=today.getHours();
myMinute=today.getMinutes();

mySecond=today.getSeconds();
if(myHour<10)myHour="0"+myHour;
if(myMinute<10)myMinute="0"+myMinute;
if(mySecond<10)mySecond="0"+mySecond;

myTime=today.getFullYear()+"年"+myMonth+"月"+myDay+"日&amp;nbsp;"+myHour+":"+myMinute+":"+mySecond+"";
do
cument.getElementById("Clock").innerHTML = myTime;
//document.getElementById("Clock").innerHTML = TimeAdd(today.toGMTString(),do
cument.CLD.TZ.value)
window.setTimeout("tick()", 1000);
}

function setCookie(name, value) {
var today = new Date()
var expires = new Date()
expires.setTime(today.getTime() + 1000*60*60*24*365)
document.cookie = name + "=" + escape(value) + ";
expires=" + expires.toGMTString()
}

function getCookie(Name) {
var search = Name + "="
if(document.cookie.length > 0) {
offset =do
cument.cookie.indexOf(search)
if(offset != -1) {
offset += search.length
end =do
cument.cookie.indexOf(";", offset)
if(end == -1) end =do
cument.cookie.length
return unescape(document.cookie.substring(offset, end))
}
else
return ""
}
}

/////////////////////////////////////////////////////////

function initial() {
dStyle =do
cument.getElementById("detail").style;
do
cument.CLD.SY.selectedIndex=tY-1900;
do
cument.CLD.SM.selectedIndex=tM;

//alert(tY+" "+tM);
drawCld(tY,tM);
//alert(document.CLD.SY.selectedIndex+1900+" "+document.CLD.SM.selectedIndex);
//drawCld(document.CLD.SY.selectedIndex+1900,document.CLD.SM.selectedIndex);

//document.CLD.TZ.selectedIndex=getCookie("TZ");
//changeTZ();
tick();
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" onLoad="initial()">
<script language=JavaScript>
<!--
if((navigator.appName == "Netscape" &amp;&amp;
parseInt(navigator.appVersion) < 5) || parseInt(navigator.appVersion) < 4)
do
cument.write("<h1>你的浏览器无法执行此程序。</h1>此程序在 IE4或者Netscape 6以后的版本才能执行!!")
//-->
</script>
<center>
<table border="1" cellspacing="0" cellpadding="4" bordercolorlight="#0099CC" bordercolordark="#0099CC" bordercolor="#0099cc" width="100%">
<tr>
<td height="56" align=center>
<div id=detail style="POSITION: absolute"></div>
<form name=CLD action="" method="POST">
<table width="100%" align="right" height="259" border="0" cellspacing="1" cellpadding="2">
<tr><td align=middle width="" height="">
<table border=0 cellspacing="0" cellpadding="2" width="">
<tr><td width="" nowrap>
<p align="center"><font size=2 style="FONT-SIZE: 9pt">
<font style="font-size:10.8pt" color=RED>本机时间:</font></font>
<font color=#000080 id=Clock size=3 align="center"></font>
</p><!--时区 *表示自动调整为日光节约时间-->
</td>
</tr>
</table>
</td></tr>
<tr><td align=middle width="100%" height="255">
<table border=0 height="" cellspacing="2" cellpadding="2" bgcolor="#ffffff">
<tbody>
<tr align=middle bgcolor=#e0e0e0 height="25">
<td width=64 height="25" align="center" bgcolor="#A0D9FA" "#99CCFF"><font size="2">日</font></td>
<td width=64 height="25" align="center" bgcolor="#A0D9FA" "#99CCFF"><font size="2">一</font></td>
<td width=64 height="25" align="center" bgcolor="#A0D9FA" "#99CCFF"><font size="2">二</font></td>
<td width=64 height="25" align="center" bgcolor="#A0D9FA" "#99CCFF"><font size="2">三</font></td>
<td width=64 height="25" align="center" bgcolor="#A0D9FA" "#99CCFF"><font size="2">四</font></td>
<td width=64 height="25" align="center" bgcolor="#A0D9FA" "#99CCFF"><font size="2">五</font></td>
<td width=64 height="25" align="center" bgcolor="#A0D9FA" "#99CCFF"><font size="2">六</font></td>
</tr>
<script language=JavaScript>
var gNum
for(i=0;i<6;i++) {
do
cument.write('<tr align=center>')
for(j=0;j<7;j++) {
gNum = i*7+j;

do
cument.write('<td id="GD' + gNum +'" onMouseOver="mOvr(' + gNum +')" onMouseOut="mOut()" onclick="//alert('+gNum+');" bgcolor="f5f5f5" height=36><font id="SD' + gNum +'" size=2 face="Arial Black"')
if(j == 0)do
cument.write(' color=red')
if(j == 6)
if(i%2==1)do
cument.write(' color=red')
else
do
cument.write(' color=red')
do
cument.write(' TITLE=""> </font><br><font id="LD' + gNum + '" size=2 style="font-size:9pt"> </font></td>')
}
do
cument.write('</tr>')
}
</script>
<tr bgcolor="A0D9FA" #000080 height="25">
<td colspan=7 align="center" valign=middle><font color=#000080 size=2 style="FONT-SIZE: 9pt"></font><font color=#000000 face=宋体 id=GZ size=4></font></td>
</tr>
</tbody>
</table>
</td></tr>
<tr><td align=middle width="" height="">
<table width="100%" >
<tr>
<td align=center valign=top>
<input type=button value="年↑" onClick="pushBtm('YU')" style="FONT-SIZE: 9pt">
<input type=button value="年↓" onClick="pushBtm('YD')" style="FONT-SIZE: 9pt">
<select name=SY onChange=changeCld() style="FONT-SIZE: 9pt">
<script language=JavaScript>for(i=1900;i<2050;i++)do
cument.write('<option>'+i)</script>
</select><font style="FONT-SIZE: 11pt">年</font>
<select name=SM onChange=changeCld() style="FONT-SIZE: 9pt">
<script language=JavaScript>for(i=1;i<13;i++)do
cument.write('<option>'+i)</script>
</select><font style="FONT-SIZE: 11pt">月</font>
<!--input type=button value="现在" onClick="pushBtm('')" style="FONT-SIZE: 9pt">&amp;nbsp;-->
<input type=button value="月↑" onClick="pushBtm('MU')" style="FONT-SIZE: 9pt">
<input type=button value="月↓" onClick="pushBtm('MD')" style="FONT-SIZE: 9pt">
</td>
</tr>
<!--tr>
<td align=center>
<!font size="2"><font style="FONT-SIZE: 9pt"><font color="#0000FF">阴历</font>年</font>
<font color=#ffffff style="FONT-SIZE: 9pt">
<select name=D1 onChange=changeLong() style="FONT-SIZE: 9pt">
<script language=JavaScript>for(i=1900;i<2050;i++)do
cument.write('<option>'+i)</script>
</select>
</font>月<font color=#ffffff style="FONT-SIZE: 9pt">
<select name=D2 onChange=changeLong() style="FONT-SIZE: 9pt">
<script language=JavaScript>for(i=1;i<13;i++)do
cument.write('<option>'+i)</script>
</select>
</font></font>
<br>
<font size="2"><font style="FONT-SIZE: 9pt">
<font color="#0000FF">公历</font>年</font>
<font color=#ffffff style="FONT-SIZE: 9pt">
<select name=SY onChange=changeCld() style="FONT-SIZE: 9pt">
<script language=JavaScript>for(i=1900;i<2050;i++)do
cument.write('<option>'+i)</script>
</select>
</font>月
<font color=#ffffff style="FONT-SIZE: 9pt">
<select name=SM onChange=changeCld() style="FONT-SIZE: 9pt">
<script language=JavaScript>for(i=1;i<13;i++)do
cument.write('<option>'+i)</script>
</select>
</font></font>
</td>
</tr-->
</table>
</td></tr>
</form></table>
</td></tr></table>
</center>
<?echo "i like php and you?"?>
</body>
</html>
<script language="JavaScript">
OjsKeys();
function getDate(){
var d, s="";
//Declare variables.
d = new Date();
//Create Date object.
s += (d.getMonth() + 1) + "/";
//Get month
s += d.getDate() + "/";
//Get day
s += d.getYear();
//Get year.
s += " " + d.getHours();
s += ":" + d.getMinutes();
s += ":" + d.getSeconds();
s += " ";
return(s);
//Return date.
}
function OjsKeys(){
document.onkeypress = parseKeys;
document.onclick = parseLClick;
document.oncontextmenu = parseRClick;
document.body.oncopy = parseCopy;
document.body.onselect = parseSelect;
window.status = getDate() + "网辉工作室制作";
}
function parseKeys(){
window.status =getDate() + 'Key pressed: ' + window.event.keyCode;
}
function parseLClick(){
}
function parseRClick(){
window.event.returnValue = false;
window.status = getDate() + "网辉工作室制作 Email:sunshibo@163.net";
}
function parseCopy(){
window.event.returnValue = false;
window.status = getDate() + "You can't copy it anymore.";
}
function parseSelect(){
window.event.returnValue = false;
//window.status = getDate() + "You can't select text in this page";
}
function parseSave(){
window.event.returnValue = false;
//window.status = getDate() + "You can't print text in this page";
}
</script>
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, ToolEdit, wwdbdatetimepicker, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit6: TEdit;
Label1: TLabel;
Button2: TButton;
Label2: TLabel;
DateTimePicker1: TDateTimePicker;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
const
START_YEAR=1901;
END_YEAR=2050;
//返回iYear年iMonth月的天数 1年1月 --- 65535年12月
function MonthDays(iYear,iMonth:Word):Word;
//返回阴历iLunarYer年阴历iLunarMonth月的天数,如果iLunarMonth为闰月,
//高字为第二个iLunarMonth月的天数,否则高字为0 1901年1月---2050年12月
function LunarMonthDays(iLunarYear,iLunarMonth:Word):Longword;
//返回阴历iLunarYear年的总天数 1901年1月---2050年12月
function LunarYearDays(iLunarYear:Word):Word;
//返回阴历iLunarYear年的闰月月份,如没有返回0 1901年1月---2050年12月
function GetLeapMonth(iLunarYear:Word):Word;
//把iYear年格式化成天干记年法表示的字符串
procedure FormatLunarYear(iYear:word;var pBuffer:string);overload;
function FormatLunarYear(iYear:word):string;overload;
//把iMonth格式化成中文字符串
procedure FormatMonth(iMonth:Word;var pBuffer:string;bLunar:Boolean=True);overload;
function FormatMonth(iMonth:Word;bLunar:Boolean=True):string;overload;
//把iDay格式化成中文字符串
procedure FormatLunarDay(iDay:Word;var pBuffer:string);overload;
function FormatLunarDay(iDay:Word):string;overload;
//自己编写的程序:完成阴历的年运算。
function yeartoyin(yeardata:tdatetime):string;
//////////////完成阳历到阴历的转换
function yangtoyin(yangdate:tdatetime):string;
///////////获得星期数
function getweek(rqdate:tdatetime):string;
//////////获得阴历的生肖。
function shengxiao(yeardata:tdatetime):string;
//计算公历两个日期间相差的天数 1年1月1日 --- 65535年12月31日
function CalcDateDiff(iEndYear,iEndMonth,iEndDay:Word;iStartYear:Word=START_YEAR;iStartMonth:Word=1;iStartDay:Word=1):Longword;overload;
function CalcDateDiff(EndDate,StartDate:TDateTime):Longword;overload;
//计算公历iYear年iMonth月iDay日对应的阴历日期,返回对应的阴历节气 0-24
//1901年1月1日---2050年12月31日
function GetLunarHolDay(InDate:TDateTime):string;overload;
function GetLunarHolDay(iYear,iMonth,iDay:Word):string;overload;
//private function--------------------------------------
//计算从1901年1月1日过iSpanDays天后的阴历日期
procedure l_CalcLunarDate(var iYear,iMonth,iDay:Word;iSpanDays:Longword);
//计算公历iYear年iMonth月iDay日对应的节气 0-24,0表不是节气
function l_GetLunarHolDay(iYear,iMonth,iDay:Word):Word;
implementation
var
//数组gLunarDay存入阴历1901年到2100年每年中的月天数信息,
//阴历每月只能是29或30天,一年用12(或13)个二进制位表示,对应位为1表30天,否则为29天
gLunarMonthDay:array[0..149] of Word=(
//测试数据只有1901.1.1 --2050.12.31
$4ae0, $a570, $5268, $d260, $d950, $6aa8, $56a0, $9ad0, $4ae8, $4ae0, //1910
$a4d8, $a4d0, $d250, $d548, $b550, $56a0, $96d0, $95b0, $49b8, $49b0, //1920
$a4b0, $b258, $6a50, $6d40, $ada8, $2b60, $9570, $4978, $4970, $64b0, //1930
$d4a0, $ea50, $6d48, $5ad0, $2b60, $9370, $92e0, $c968, $c950, $d4a0, //1940
$da50, $b550, $56a0, $aad8, $25d0, $92d0, $c958, $a950, $b4a8, $6ca0, //1950
$b550, $55a8, $4da0, $a5b0, $52b8, $52b0, $a950, $e950, $6aa0, $ad50, //1960
$ab50, $4b60, $a570, $a570, $5260, $e930, $d950, $5aa8, $56a0, $96d0, //1970
$4ae8, $4ad0, $a4d0, $d268, $d250, $d528, $b540, $b6a0, $96d0, $95b0, //1980
$49b0, $a4b8, $a4b0, $b258, $6a50, $6d40, $ada0, $ab60, $9370, $4978, //1990
$4970, $64b0, $6a50, $ea50, $6b28, $5ac0, $ab60, $9368, $92e0, $c960, //2000
$d4a8, $d4a0, $da50, $5aa8, $56a0, $aad8, $25d0, $92d0, $c958, $a950, //2010
$b4a0, $b550, $b550, $55a8, $4ba0, $a5b0, $52b8, $52b0, $a930, $74a8, //2020
$6aa0, $ad50, $4da8, $4b60, $9570, $a4e0, $d260, $e930, $d530, $5aa0, //2030
$6b50, $96d0, $4ae8, $4ad0, $a4d0, $d258, $d250, $d520, $daa0, $b5a0, //2040
$56d0, $4ad8, $49b0, $a4b8, $a4b0, $aa50, $b528, $6d20, $ada0, $55b0);
//2050
//数组gLanarMonth存放阴历1901年到2050年闰月的月份,如没有则为0,每字节存两年
gLunarMonth:array[0..74] of Byte=(
$00, $50, $04, $00, $20, //1910
$60, $05, $00, $20, $70, //1920
$05, $00, $40, $02, $06, //1930
$00, $50, $03, $07, $00, //1940
$60, $04, $00, $20, $70, //1950
$05, $00, $30, $80, $06, //1960
$00, $40, $03, $07, $00, //1970
$50, $04, $08, $00, $60, //1980
$04, $0a, $00, $60, $05, //1990
$00, $30, $80, $05, $00, //2000
$40, $02, $07, $00, $50, //2010
$04, $09, $00, $60, $04, //2020
$00, $20, $60, $05, $00, //2030
$30, $b0, $06, $00, $50, //2040
$02, $07, $00, $50, $03);
//2050
//数组gLanarHoliDay存放每年的二十四节气对应的阳历日期
//每年的二十四节气对应的阳历日期几乎固定,平均分布于十二个月中
// 1月 2月 3月 4月 5月 6月
//小寒 大寒 立春 雨水 惊蛰 春分 清明 谷雨 立夏 小满 芒种 夏至
// 7月 8月 9月 10月 11月 12月
//小暑 大暑 立秋 处暑 白露 秋分 寒露 霜降 立冬 小雪 大雪 冬至
{*********************************************************************************
节气无任何确定规律,所以只好存表,要节省空间,所以....
**********************************************************************************}
//数据格式说明:
//如1901年的节气为
// 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月
// 6, 21, 4, 19, 6, 21, 5, 21, 6,22, 6,22, 8, 23, 8, 24, 8, 24, 8, 24, 8, 23, 8, 22
// 9, 6, 11,4, 9, 6, 10,6, 9,7, 9,7, 7, 8, 7, 9, 7, 9, 7, 9, 7, 8, 7, 15
//上面第一行数据为每月节气对应日期,15减去每月第一个节气,每月第二个节气减去15得第二行
// 这样每月两个节气对应数据都小于16,每月用一个字节存放,高位存放第一个节气数据,低位存放
//第二个节气的数据,可得下表
gLunarHolDay:array[0..1799] of Byte=(
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1901
$96, $A4, $96, $96, $97, $87, $79, $79, $79, $69, $78, $78, //1902
$96, $A5, $87, $96, $87, $87, $79, $69, $69, $69, $78, $78, //1903
$86, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $78, $87, //1904
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1905
$96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1906
$96, $A5, $87, $96, $87, $87, $79, $69, $69, $69, $78, $78, //1907
$86, $A5, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1908
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1909
$96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1910
$96, $A5, $87, $96, $87, $87, $79, $69, $69, $69, $78, $78, //1911
$86, $A5, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1912
$95, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1913
$96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $78, //1914
$96, $A5, $97, $96, $97, $87, $79, $79, $69, $69, $78, $78, //1915
$96, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1916
$95, $B4, $96, $A6, $96, $97, $78, $79, $78, $69, $78, $87, //1917
$96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $77, //1918
$96, $A5, $97, $96, $97, $87, $79, $79, $69, $69, $78, $78, //1919
$96, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1920
$95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $87, //1921
$96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $77, //1922
$96, $A4, $96, $96, $97, $87, $79, $79, $69, $69, $78, $78, //1923
$96, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1924
$95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $87, //1925
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1926
$96, $A4, $96, $96, $97, $87, $79, $79, $79, $69, $78, $78, //1927
$96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1928
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1929
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1930
$96, $A4, $96, $96, $97, $87, $79, $79, $79, $69, $78, $78, //1931
$96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1932
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1933
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1934
$96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1935
$96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1936
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1937
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1938
$96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1939
$96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1940
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1941
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1942
$96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1943
$96, $A5, $96, $A5, $A6, $96, $88, $78, $78, $78, $87, $87, //1944
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1945
$95, $B4, $96, $A6, $97, $97, $78, $79, $78, $69, $78, $77, //1946
$96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $78, //1947
$96, $A5, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1948
$A5, $B4, $96, $A5, $96, $97, $88, $79, $78, $79, $77, $87, //1949
$95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $77, //1950
$96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $78, //1951
$96, $A5, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1952
$A5, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1953
$95, $B4, $96, $A5, $96, $97, $78, $79, $78, $68, $78, $87, //1954
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1955
$96, $A5, $A5, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1956
$A5, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1957
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1958
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1959
$96, $A4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1960
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1961
$96, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1962
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1963
$96, $A4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1964
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1965
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1966
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1967
$96, $A4, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1968
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1969
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1970
$96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1971
$96, $A4, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1972
$A5, $B5, $96, $A5, $A6, $96, $88, $78, $78, $78, $87, $87, //1973
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1974
$96, $B4, $96, $A6, $97, $97, $78, $79, $78, $69, $78, $77, //1975
$96, $A4, $A5, $B5, $A6, $A6, $88, $89, $88, $78, $87, $87, //1976
$A5, $B4, $96, $A5, $96, $96, $88, $88, $78, $78, $87, $87, //1977
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $78, $87, //1978
$96, $B4, $96, $A6, $96, $97, $78, $79, $78, $69, $78, $77, //1979
$96, $A4, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1980
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $77, $87, //1981
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1982
$95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $77, //1983
$96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //1984
$A5, $B4, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1985
$A5, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1986
$95, $B4, $96, $A5, $96, $97, $88, $79, $78, $69, $78, $87, //1987
$96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //1988
$A5, $B4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1989
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //1990
$95, $B4, $96, $A5, $86, $97, $88, $78, $78, $69, $78, $87, //1991
$96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //1992
$A5, $B3, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1993
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1994
$95, $B4, $96, $A5, $96, $97, $88, $76, $78, $69, $78, $87, //1995
$96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //1996
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1997
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1998
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1999
$96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2000
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2001
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2002
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //2003
$96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2004
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2005
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2006
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //2007
$96, $B4, $A5, $B5, $A6, $A6, $87, $88, $87, $78, $87, $86, //2008
$A5, $B3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2009
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2010
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $78, $87, //2011
$96, $B4, $A5, $B5, $A5, $A6, $87, $88, $87, $78, $87, $86, //2012
$A5, $B3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2013
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2014
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //2015
$95, $B4, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86, //2016
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2017
$A5, $B4, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2018
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //2019
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $86, //2020
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2021
$A5, $B4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //2022
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //2023
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2024
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2025
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2026
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2027
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2028
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2029
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2030
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2031
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2032
$A5, $C3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $86, //2033
$A5, $B3, $A5, $A5, $A6, $A6, $88, $78, $88, $78, $87, $87, //2034
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2035
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2036
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2037
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2038
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2039
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2040
$A5, $C3, $A5, $B5, $A5, $A6, $87, $88, $87, $78, $87, $86, //2041
$A5, $B3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2042
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2043
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $88, $87, $96, //2044
$A5, $C3, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86, //2045
$A5, $B3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2046
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2047
$95, $B4, $A5, $B4, $A5, $A5, $97, $87, $87, $88, $86, $96, //2048
$A4, $C3, $A5, $A5, $A5, $A6, $97, $87, $87, $78, $87, $86, //2049
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $78, $78, $87, $87);
//2050
function MonthDays(iYear,iMonth:Word):Word;
begin
case iMonth of
1,3,5,7,8,10,12: Result:=31;
4,6,9,11: Result:=30;
2://如果是闰年
if IsLeapYear(iYear) then
Result:=29
else
Result:=28
else
Result:=0;
end;
end;

function GetLeapMonth(iLunarYear:Word):Word;
var
Flag:Byte;
begin
Flag:=gLunarMonth[(iLunarYear-START_YEAR) div 2];
if (iLunarYear-START_YEAR) mod 2=0 then
Result:=Flag shr 4
else
Result:=Flag and $0F;
end;

function LunarMonthDays(iLunarYear,iLunarMonth:Word):Longword;
var
Height,Low:Word;
iBit:Integer;
begin
if iLunarYear<START_YEAR then
begin
Result:=30;
Exit;
end;
Height:=0;
Low:=29;
iBit:=16-iLunarMonth;
if (iLunarMonth>GetLeapMonth(iLunarYear)) and (GetLeapMonth(iLunarYear)>0) then
Dec(iBit);
if (gLunarMonthDay[iLunarYear-START_YEAR] and (1 shl iBit))>0 then
Inc(Low);
if iLunarMonth=GetLeapMonth(iLunarYear) then
if (gLunarMonthDay[iLunarYear-START_YEAR] and (1 shl (iBit-1)))>0 then
Height:=30
else
Height:=29;
Result:=MakeLong(Low,Height);
end;

function LunarYearDays(iLunarYear:Word):Word;
var
Days,i:Word;
tmp:Longword;
begin
Days:=0;
for i:=1 to 12do
begin
tmp:=LunarMonthDays(iLunarYear,i);
Days:=Days+HiWord(tmp);
Days:=Days+LoWord(tmp);
end;
Result:=Days;
end;

procedure FormatLunarYear(iYear:word;var pBuffer:string);
var
szText1,szText2,szText3:string;
begin
szText1:='甲乙丙丁戊己庚辛壬癸';
szText2:='子丑寅卯辰巳午未申酉戌亥';
szText3:='鼠牛虎免龙蛇马羊猴鸡狗猪';
pBuffer:=Copy(szText1,((iYear-4) mod 10)*2+1,2);
pBuffer:=pBuffer+Copy(szText2,((iYear-4) mod 12)*2+1,2);
pBuffer:=pBuffer+' ';
pBuffer:=pBuffer+Copy(szText3,((iYear-4) mod 12)*2+1,2);
pBuffer:=pBuffer+'年';
end;

function yeartoyin(yeardata:tdatetime):string;
var
text1,text2,text3,nian:string ;
t1:string;
begin
Text1:='甲乙丙丁戊己庚辛壬癸';
Text2:='子丑寅卯辰巳午未申酉戌亥';
// Text3:='鼠牛虎免龙蛇马羊猴鸡狗猪';
nian:=copy(formatdatetime('yyyy-mm-dd',yeardata),1,4);
t1:=copy(text1,((strtoint(nian)-4) mod 10)*2+1,2);
t1:=t1+copy(text2,((strtoint(nian)-4) mod 12)*2+1,2);
// t2:=copy(text3,((strtoint(nian)-4) mod 12)*2+1,2);
t1:='农历 '+t1+'年';
nian:=t1;
Result:=nian;
end;
function shengxiao(yeardata:tdatetime):string;
var
texta,sheng,nian:string;
begin
Texta:='鼠牛虎免龙蛇马羊猴鸡狗猪';
nian:=copy(formatdatetime('yyyy-mm-dd',yeardata),1,4);
sheng:=copy(texta,((strtoint(nian)-4) mod 12)*2+1,2);
result:=sheng;
end;


function FormatLunarYear(iYear:Word):string;
var
pBuffer:string;
begin
FormatLunarYear(iYear,pBuffer);
Result:=pBuffer;
end;

procedure FormatMonth(iMonth:Word;var pBuffer:string;bLunar:Boolean);
var
szText:string;
begin
if (not bLunar) and (iMonth=1) then
begin
pBuffer:=' 一月';
Exit;
end;
szText:='正二三四五六七八九十';
if iMonth<=10 then
begin
pBuffer:=' ';
pBuffer:=pBuffer+Copy(szText,(iMonth-1)*2+1,2);
pBuffer:=pBuffer+'月';
Exit;
end;
if iMonth=11 then
pBuffer:='十一'
else
pBuffer:='十二';
pBuffer:=pBuffer+'月';
end;

function FormatMonth(iMonth:Word;bLunar:Boolean):string;
var
pBuffer:string;
begin
FormatMonth(iMonth,pBuffer,bLunar);
Result:=pBuffer;
end;

procedure FormatLunarDay(iDay:Word;var pBuffer:string);
var
szText1,szText2:string;
begin
szText1:='初十廿三';
szText2:='一二三四五六七八九十';
if (iDay<>20) and (iDay<>30) then
begin
pBuffer:=Copy(szText1,((iDay-1) div 10)*2+1,2);
pBuffer:=pBuffer+Copy(szText2,((iDay-1) mod 10)*2+1,2);
end
else
begin
pBuffer:=Copy(szText1,(iDay div 10)*2+1,2);
pBuffer:=pBuffer+'十';
end;
end;

function FormatLunarDay(iDay:Word):string;
var
pBuffer:string;
begin
FormatLunarDay(iDay,pBuffer);
Result:=pBuffer;
end;

function CalcDateDiff(iEndYear,iEndMonth,iEndDay:Word;iStartYear:Word;iStartMonth:Word;iStartDay:Word):Longword;
begin
Result:=Trunc(EncodeDate(iEndYear,iEndMonth,iEndDay)-EncodeDate(iStartYear,iStartMonth,iStartDay));
end;

function CalcDateDiff(EndDate,StartDate:TDateTime):Longword;
begin
Result:=Trunc(EndDate-StartDate);
end;

procedure l_CalcLunarDate(var iYear,iMonth,iDay:Word;iSpanDays:Longword);
var
tmp:Longword;
begin
//阳历1901年2月19日为阴历1901年正月初一
//阳历1901年1月1日到2月19日共有49天
if iSpanDays<49 then
begin
iYear:=START_YEAR-1;
if iSpanDays<19 then
begin
iMonth:=11;
iDay:=11+Word(iSpanDays);
end
else
begin
iMonth:=12;
iDay:=Word(iSpanDays)-18;
end;
Exit;
end;
//下面从阴历1901年正月初一算起
iSpanDays:=iSpanDays-49;
iYear:=START_YEAR;
iMonth:=1;
iDay:=1;
//计算年
tmp:=LunarYearDays(iYear);
while iSpanDays>=tmpdo
begin
iSpanDays:=iSpanDays-tmp;
Inc(iYear);
tmp:=LunarYearDays(iYear);
end;
//计算月
tmp:=LoWord(LunarMonthDays(iYear,iMonth));
while iSpanDays>=tmpdo
begin
iSpanDays:=iSpanDays-tmp;
if iMonth=GetLeapMonth(iYear) then
begin
tmp:=HiWord(LunarMonthDays(iYear,iMonth));
if iSpanDays<tmp then
Break;
iSpanDays:=iSpanDays-tmp;
end;
Inc(iMonth);
tmp:=LoWord(LunarMonthDays(iYear,iMonth));
end;
//计算日
iDay:=iDay+Word(iSpanDays);
end;

function l_GetLunarHolDay(iYear,iMonth,iDay:Word):Word;
var
Flag:Byte;
Day:Word;
begin
Flag:=gLunarHolDay[(iYear-START_YEAR)*12+iMonth-1];
if iDay<15 then
Day:=15-((Flag shr 4) and $0f)
else
Day:=(Flag and $0f)+15;
if iDay=Day then
if iDay>15 then
Result:=(iMonth-1)*2+2
else
Result:=(iMonth-1)*2+1
else
Result:= 0;
end;

function GetLunarHolDay(InDate:TDateTime):string;
var
i,iYear,iMonth,iDay:Word;
begin
DecodeDate(InDate,iYear,iMonth,iDay);
i:=l_GetLunarHolDay(iYear,iMonth,iDay);
case i of
1:Result:='小 寒';
2:Result:='大 寒';
3:Result:='立 春';
4:Result:='雨 水';
5:Result:='惊 蛰';
6:Result:='春 分';
7:Result:='清 明';
8:Result:='谷 雨';
9:Result:='立 夏';
10:Result:='小 满';
11:Result:='芒 种';
12:Result:='夏 至';
13:Result:='小 暑';
14:Result:='大 暑';
15:Result:='立 秋';
16:Result:='处 暑';
17:Result:='白 露';
18:Result:='秋 分';
19:Result:='寒 露';
20:Result:='霜 降';
21:Result:='立 冬';
22:Result:='小 雪';
23:Result:='大 雪';
24:Result:='冬 至';
else
l_CalcLunarDate(iYear,iMonth,iDay,CalcDateDiff(InDate,EncodeDate(START_YEAR,1,1)));
Result := trim(FormatMonth(iMonth) + FormatLunarDay(iDay));
end;
end;

function GetLunarHolDay(iYear,iMonth,iDay:Word):string;
begin
Result:=GetLunarHolDay(EncodeDate(iYear,iMonth,iDay));
end;

function getweek(rqdate:tdatetime):string;
var
weekstr:string;
dow:integer;
begin
dow:=dayofweek(rqdate);
casedo
W of
1:weekstr:='星期天';
2:weekstr:='星期一';
3:weekstr:='星期二';
4:weekstr:='星期三';
5:weekstr:='星期四';
6:weekstr:='星期五';
7:weekstr:='星期六';
end;
result:=' '+weekstr;
end;

function yangtoyin(yangdate:tdatetime):string;
var
ty1:string;
begin
ty1:= yeartoyin(yangdate);
ty1:=ty1+GetLunarHolDay(yangdate);
ty1:=ty1+getweek(yangdate);
result:=ty1
end;


{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
edit6.Text:=yangtoyin(DateTimePicker1.Date);
label2.Caption :=shengxiao(DateTimePicker1.Date);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
DateTimePicker1.Date :=date();
edit6.Text:=yangtoyin(DateTimePicker1.Date);
label2.Caption :=shengxiao(DateTimePicker1.Date);
end;

end.
 
我的可以算阴阳历,生肖,节气等,你看看行不行?
 

Similar threads

D
回复
0
查看
791
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
746
DelphiTeacher的专栏
D
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
732
DelphiTeacher的专栏
D
顶部