<marquee width=358>欢迎来到月影社区,希望这里可以成为您美丽的梦幻花园,如果你觉得这里好请分享给您的朋友!- wf66.com</marquee> 将月影社区设置为您的首页将月影社区地址加入到您的收藏栏
月影社区时尚音乐音乐查询IP手机许愿之瓶最新更新文件加密访客留言爱音乐
欢迎您,首页 >> 信息中心 >> 使用ASP编写农历算法(一)

请输入您关键字:


使用ASP编写农历算法(一)

推荐查看本文HTML版本


使用ASP编写农历算法 
新年将近,呵呵,写了一个阴历和阳历的ASP程序,就当给大家的新年贺礼
(呵呵,这下蓝先生满意啦把,就当我送给你的圣诞礼物把。。。)
希望大家能够喜欢。。。大家可以很方便的将这个农历加入到自己的主页中
中国人使用中国人自己的日历,呵呵,希望大家以后能够支持Chinaasp的
共同进步。。。
一共两个文件cal.asp和cal2.inc(主要是常量的定义)
cal.asp代码如下
<!--#include virtual="cal2.inc"-->
<%
Function GongDataIsValid(m_date)
if Not IsDate(m_date) Then
GongDataIsValid = False [月影读书频道 http://wf66.com/]
Exit Function
else [月影读书频道 http://wf66.com/]
if Year(m_date) >1950 AND Year(m_date) < 2050 Then
GongDataIsValid = true
Exit Function
else
if Year(m_date)=1950 Then
if Month(m_date)>2 Then
GongDataIsValid = true
Exit Function
else
if Month(m_date)=2 Then
if Day(m_date) > 16 Then
GongDataIsValid = true
Exit Function
End If
End If
End If
End If
End If
End If
GongDataIsValid = FALSE
End Function

Function NongDataIsValid(m_date)
if Year(m_date) > 1949 AND Year(m_date) < 2049 Then
NongDataIsValid = true
Exit Function
else
if Year(m_date)=2049 Then
if Month(m_date.month) < 12 Then
NongDataIsValid = true
Exit Function
else
if Month(m_date)=12 Then
if Day(m_date) < 8 Then
NongDataIsValid = true
Exit Function
End If
End If
End If
End If
End If
NongDataIsValid = False
End Function

Function ConvertToGongLi(m_nongli)
Dim days
Dim years
Dim alldays
Dim result

days= DaysFromSpringDay(m_nongli)
days= days + GetDaysFromStart(Year(m_nongli))
years = Year(m_nongli)
alldays = GetGongYearDays(years)
if days > alldays Then
days = days - alldays
years = years + 1
end If
result = CalGongDate(years,days)
ConvertToGongLi = result
End Function

Function ConvertToNongLi(m_gongli)
Dim days
Dim years
Dim alldays
Dim result

days= DaysFromNewYear(m_gongli)
alldays = GetDaysFromStart(Year(m_gongli))
years = Year(m_gongli)
if days <= alldays Then
years = years - 1
days = days + GetGongYearDays(years)
end if
days = days - GetDaysFromStart(years)
result = CalNongDate(years,days)
ConvertToNongLi = result
end function

Function GetDateAfterDays(m_first,m_days)
Dim m_firstdays
m_firstdays = DaysFromNewYear(m_first) + m_days
GetDateAfterDays = CalGongDate(Year(m_first),m_firstdays)
End Function

Function CalGongDate(years,days)
Dim resultday,resultyear,resultmonth
dim caldays
caldays = 0
resultyear = years
for i=1 To 13 - 1
caldays =caldays + GetGongMonthDays(years,i)
if caldays>=days then
caldays = caldays - GetGongMonthDays(year,i)
resultmonth = i
resultday=days-caldays
exit for
end if
next
CalGongDate=resultyear & "-" & resultmonth & "-" & resultday
end function

function CalNongDate(years,days)
Dim resultday,resultyear,resultmonth
dim caldays
caldays = 0

resultyear = years
IsRunyue = false

for i=1 to 12
caldays = caldays + GetNotRunNongMonthDays(years,i)
if caldays>=days then
caldays = caldays - GetNotRunNongMonthDays(years,i)
resultmonth = i
resultday = days - caldays
IsRunyue = false
exit for
else
if GetNongRunYue(years) = i then 
caldays = caldays + GetNongRunYueDays(years)
if caldays>=days then
caldays = caldays - GetNongRunYueDays(years)
resultmonth = i
resultday = days - caldays
IsRunyue = true
exit for
end if
end if
end if
next
CalNongDate=resultyear & "-" & resultmonth & "-" & resultday
end function


function GetGongMonthDays(years,months)
GetGongMonthDays = 30
if months = 2 then
if YearIsRunNian(years) Then
GetGongMonthDays = 29
else
GetGongMonthDays = 28
end if
else
if GongMonthIsLarge(months) Then
GetGongMonthDays = 31
else
GetGongMonthDays = 30
end if
end if
end function

function GetNongLiDayName(mdays)
Dim i,j

i = InStr(mdays,"-")
j = InStr(i+1,mdays,"-")
GetNongLiDayName = Right(mdays,Len(mdays) - j)
GetNongLiDayName = NongLiDayName(Int(GetNongLiDayName) - 1)
end function

function GetNongLiMonthName(mdays)
Dim i,j

i = InStr(mdays,"-")
j = InStr(i+1,mdays,"-")
GetNongLiMonthName = Mid(mdays,i+1,j-i-1)
GetNongLiMonthName = NongLiMonthName(Int(GetNongLiMonthName) - 1)
end function

function GetNotRunNongMonthDays(years,months)
if NongMonthIsLarge(years,months) Then
GetNotRunNongMonthDays = 30
else
GetNotRunNongMonthDays = 29
end if
end function

function GetNongMonthDays(years,months,m_run)
Dim days
days = 0
if m_run then
days = GetNongRunYueDays(years)
else
days = GetNotRunNongMonthDays(years,months)
end if
GetNongMonthDays = days
end function

function GetGongYearDays(years)
if YearIsRunNian(years) then
GetGongYearDays = 366
else
GetGongYearDays = 365
end if
end function

function GetNongYearDays(years)
dim days
days = 0
for i=1 To 12
days =days + GetNongMonthDays(years,i,false)
next
days =days + GetNongRunYueDays(years)
GetNongYearDays = days
end function

function GetNongRunYueDays(years)
if GetNongRunYue(years) =0 then
GetNongRunYueDays = 0
exit function
end if
if RunYueIsLarge(years) then
GetNongRunYueDays = 30
else
GetNongRunYueDays = 29
end if
end function

function DaysFromNewYear(m_day)
Dim days
days = 0
for i=1 to Month(m_day) - 1
days = days + GetGongMonthDays(year(m_day),i)
next
days = days + Day(m_day)
DaysFromNewYear = days
end function
function DaysFromSpringDay(m_day)
Dim days
Dim months
days = 0
months = GetNongRunYue(year(m_day))
if months < Month(m_day) then
days = days + GetNongRunYueDays(year(m_day))
else
if((months=Month(m_day)) AND IsRunyue) then
days = days + GetNongRunYueDays(year(m_day))
end if
end if
for i=1 to Month(m_day)
days = days + GetNongMonthDays(year(m_day),i,false)
next
days = days + Day(m_day)
DaysFromSpringDay = days
end function

function Cal2N(n)
Cal2N = 1
for i=0 to n - 1
Cal2N = Cal2N * 2
next
end function

function GetNNameIn60(index)
Dim ShengXiao
Dim TianGan
Dim DiZhi
Dim buffer
Dim m_cur,m_this,tian,di
ShengXiao = Array
("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪") [月影读书频道 http://wf66.com/]
TianGan = Array
("甲","乙","丙","丁","戊","己","庚","辛","壬","癸")
DiZhi= Array
("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥")

buffer = "农历"

m_cur = 0
m_this = 0
tian = 0
di= 0
for i=0 to 60 - 1
tian = i mod 10
di = i mod 12
if m_this = index then
buffer = buffer & TianGan(tian)
buffer = buffer & DiZhi(di)
buffer = buffer & "年,"
buffer = buffer & ShengXiao(di)
buffer = buffer & "年"
end if
m_this = m_this + 1
next
GetNNameIn60 = buffer
end function

function GetGanZhi(m_nongyear) 
dim m_index
m_index = (m_nongyear - 1924) mod 60
GetGanZhi = GetNNameIn60(m_index)
end function

function YearIsRunNian(years)
YearIsRunNian = CalendarData(years-m_minyear,0) AND &H80
end function

function RunYueIsLarge(years)
RunYueIsLarge = CalendarData(years-m_minyear,0) AND &H40
end function


使用ASP编写农历算法(一) 2006-8-28
转到本主题第:[ 1 ]
相关评论

暂无评论

总计0页 [ ]上一页 下一页
发表评论(揪错)
呢称: * 您尚未登陆,请登录
来自: *
内容:
 

(为防止非法信息,您的言论提交后需要审核才能正常显示)

文学
精品文萃 情感天地 言情小说
网络小说 玄幻小说 悬疑恐怖
武侠小说 古典品谈 外国名著
儿童文学 会员原创 学习园地
杂谈其它
娱乐
爆笑网文 星座占卜 影音动漫
娱乐新闻 影视剧情
诗词
青竹诗歌 个人诗集 宋词雅赏
全唐诗录
新闻
国际新闻 国内新闻 科技新闻
体育新闻
图片
图文专区 艺术长廊 桌面壁纸
精品素材 像素图片
漫画
单幅漫画 爆笑四格 连环漫画
电脑
电脑入门 图形图像 编程开发
游戏
我爱Q宠 最新攻略 最新秘籍
游戏新闻 技巧心得
经济
帕格节电 财经资讯 股市证券
生活
百科知识 外语学院 潮流时尚
健康医疗 宠物花卉 汽车地带
行走天下
美食
面食甜点 家常菜品 药膳食疗
美食天下 烹饪技巧 松辽风味
燕京风味 巴蜀风味 滇黔风味
赣江风味 徽皖风味 闽台风味
齐鲁风味 中州风味 岭南风味
荆楚风味 三晋风味 淞沪风味
苏扬风味 潇湘风味 钱塘风味
民族风味 素斋仿荤
营销
管理杂谈 谈经论道 培训激励
经营战略 职场生涯 公关交际
关于我们版权声明本站导航友情连结作品演示 TOP↑
本论坛言论纯属发表者个人意见,与£月影社区£立场无关。 皖ICP备16024038号-1
禁止发布任何色情/政治/反动相关信息让我们共同来营造一个属于我们的梦幻家园
Copyright ©2001-2006 MoonShadow. All rights reserved.  Version 4.0  Licence 2006.4.2
建站天数:7242天 本站基于ASP+JS构建,完全自主开发,版权归属月影社区 管理员QQ:23165062 Time:46ms