如题所述
提供一个ASP算法,
<%
function tuisuan(nian,yue,ri,shi,fen,miao,ngz,ygz,rgz,sgz,yinli,jiaojie)
dim tg(10)
dim dz(12)
dim jq(24)
tg(0)="甲"
tg(1)="乙"
tg(2)="丙"
tg(3)="丁"
tg(4)="戊"
tg(5)="己"
tg(6)="庚"
tg(7)="辛"
tg(8)="壬"
tg(9)="癸"'天干名称
dz(0)="子"
dz(1)="丑"
dz(2)="寅"
dz(3)="卯"
dz(4)="辰"
dz(5)="巳"
dz(6)="午"
dz(7)="未"
dz(8)="申"
dz(9)="酉"
dz(10)="戌"
dz(11)="亥"'地支名称
jq(0)="立春"
jq(1)="雨水"
jq(2)="惊蛰"
jq(3)="春分"
jq(4)="清明"
jq(5)="谷雨"
jq(6)="立夏"
jq(7)="小满"
jq(8)="芒种"
jq(9)="夏至"
jq(10)="小暑"
jq(11)="大暑"
jq(12)="立秋"
jq(13)="处暑"
jq(14)="白露"
jq(15)="秋分"
jq(16)="寒露"
jq(17)="霜降"
jq(18)="立冬"
jq(19)="小雪"
jq(20)="大雪"
jq(21)="冬至"
jq(22)="小寒"
jq(23)="大寒"'节气名称
shijian=nian&"-"&yue&"-"&ri&" "&shi&":"&fen&":"&miao
set fo=server.createobject("scripting.filesystemobject")
path=server.mappath("jieqi.txt")
set cal=fo.opentextfile(path)'读取24节气交节时刻表
tag=true
i=0
while not cal.atendofstream and tag
str=cal.readline
strarr=split(str,",")
jieqi=strarr(1)&"-"&strarr(2)&"-"&strarr(3)&" "&strarr(4)&":"&strarr(5)&":"&strarr(6)
zhongqi=strarr(1)&"-"&strarr(2)&"-"&strarr(7)&" "&strarr(8)&":"&strarr(9)&":"&strarr(10)
if trim(strarr(1))=trim(nian) then
i=i+1
if datediff("d",shijian,jieqi)<=0 and datediff("d",shijian,zhongqi)>0 then
tag=false
gzyue=strarr(2)-1
if gzyue=0 then
gzyue=12
end if
if strarr(2)>=2 then
gznian=strarr(1)
else
gznian=strarr(1)-1
end if
jiaojie=jq((2*i+20)mod 24)&":"&jieqi&" "&jq(((2*i+20)mod 24)+1)&":"&zhongqi
elseif datediff("d",shijian,jieqi)>=0 and datediff("d",shijian,zhongqi)>=0 then
tag=false
gzyue=strarr(2)-2
if gzyue=0 then
gzyue=12
end if
if strarr(2)>=3 then
gznian=strarr(1)
else
gznian=strarr(1)-1
end if
end if
end if
if tag then
jiaojie=jq((2*i+20)mod 24)&":"&jieqi&" "&jq(((2*i+20)mod 24)+1)&":"&zhongqi
end if
wend
cal.close'获取当前日期相邻的两个交节时刻
……
sdz=shi+1
sdz=int(sdz/2)
sdz=sdz+1
if sdz>12 then
sdz=sdz-12
end if
stg=rtg*2+sdz-12
if stg>10 then
stg=stg-10
elseif stg<=0 then
stg=stg+10
end if
sgz=tg(stg-1)&dz(sdz-1)'推算时干支
end function
%>
来源: