首页 >> 读书频道 >> 电脑 >> 使用ASP编写农历算法(一)
 
· 也谈在asp聊天室程序中
· 实现聊天室的悄悄话功能(
· 实现聊天室的悄悄话功能(
· 实现聊天室的悄悄话功能(
· 一个只有一个文件,功能强
· 多层回复的基于 ASP
· 多层回复的基于 ASP
· 多层回复的基于 ASP
· 建立一个小型的购物车程序
· 制作购物车程序!
· 同时订购多样物品的源程序
· ASP商场源程序
 
· 全唐诗卷四十六
· 韩剧《布拉格恋人》剧情介
· 夜航船[作者:明·张岱]
· 局外人[作者:韩·可爱淘
· 现场流行病学
· 源氏物语[日本:紫式部]
· 红楼梦:120回全本[清
· 武林寓言故事
· 2006高考录取规则
· 首批中国世界名牌产品和2
· 济南美食大全
· 管理三十六计
 
· (出租)中动商场部分及写
· (出租)中动动漫基地&#
· 喜剧学院
· 《善德女王》剧情介绍
· 魔女18号 剧情
· 丑女无敌剧情介绍
· 魔女幼熙剧情介绍
· 龙游天下剧情介绍
· 震撼世界的七日剧情介绍
· 静静的白桦林剧情介绍
· 心情日记—老公今天我想对
· 旗舰剧情介绍
欢迎来到月影社区!如果您觉得这里不错,请推荐给您的朋友们。月影社区:http://wf66.com/

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


查看有无更新版本

关键字:代码乐园 2006-8-28

 

使用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
Exit Function
else
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
("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪")
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编写农历算法(一)

[ 1 ]
使用ASP编写农历算法(一) num

打印本页 关闭

关于我们版权声明本站导航友情连结作品演示 TOP↑