使用ASP编写农历算法(二)(转)

function GetDaysFromStart(years)
  GetDaysFromStart = (CalendarData(years-m_minyear,0) AND &H3f)
end function

function NongMonthIsLarge(years,months)
  NongMonthIsLarge = false
  if(months<9) then
    if(CalendarData(years-m_minyear,1) AND Cal2N(8 - months)) then
      NongMonthIsLarge = true
    end if
  else
    ch=Cal2N(12 - months)
    ch=MoveBit(ch)
    if(CalendarData(years-m_minyear,2) AND ch) then  
NongMonthIsLarge = true
  end if
end function

function GetNongRunYue(years)
  GetNongRunYue = (CalendarData(years-m_minyear,2) AND &H0f)
end function

function GongMonthIsLarge(months)
  GongMonthIsLarge = false
  if months < 8 then
    if (months mod 2) <> 0 then
      GongMonthIsLarge = true
    end if
  else
    if ((months mod 2) = 0) then
      GongMonthIsLarge = true
    end if
  end if
end function

%>

Dim DisplayNongLiDate
Function GetDaysInMonth(iMonth, iYear)
  Select Case iMonth
    Case 1, 3, 5, 7, 8, 10, 12
      GetDaysInMonth = 31
    Case 4, 6, 9, 11
      GetDaysInMonth = 30
    Case 2
      If IsDate("February 29, " & iYear) Then
        GetDaysInMonth = 29
      Else
        GetDaysInMonth = 28
      End If
  End Select
End Function

Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
  Dim dTemp
  dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1),
dAnyDayInTheMonth)
  GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function

Function SubtractOneMonth(dDate)
  SubtractOneMonth = DateAdd("m", -1, dDate)
End Function

Function AddOneMonth(dDate)
  AddOneMonth = DateAdd("m", 1, dDate)
End Function


Dim dDate  
Dim iDIM   
Dim iDOW   
Dim iCurrent 
Dim iPosition

If IsDate(Request.QueryString("date")) Then
  dDate = CDate(Request.QueryString("date"))
Else
  If IsDate(Request.QueryString("month") & "-" & Request.QueryString
("day") & "-" & Request.QueryString("year")) Then
    dDate = CDate(Request.QueryString("month") & "-" &
Request.QueryString("day") & "-" & Request.QueryString("year"))
  Else
    dDate = Date()
    
    If Len(Request.QueryString("month")) <> 0 Or Len
(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("year"))
<> 0 Or Len(Request.QueryString("date")) <> 0 Then
      Response.Write "对不起,你选择的日期非法,日期自动设置为当前日期.

"
    End If
  End If
End If

iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)

%>



      
<<MonthName(Month(dDate)) & " " & Year(dDate) %> GetGanZhi(Year(dDate))%>>>

    
星期

spacer.gifBORDER=0>
星期

spacer.gifBORDER=0>
星期

spacer.gifBORDER=0>
星期

spacer.gifBORDER=0>
星期

spacer.gifBORDER=0>
星期

spacer.gifBORDER=0>
星期

spacer.gifBORDER=0>

iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
  If iPosition = 1 Then
    Response.Write vbTab & "

SIZE=""-1"">" & iCurrent & "
"
    DisplayNongLiDate = ConvertToNongLi(FormatDateTime(dDate,1))
    Response.Write vbTab & GetNongLiMonthName(DisplayNongLiDate)
& "月" & GetNongLiDayName(DisplayNongLiDate) & "
date=" & Month(dDate) & "-" & iCurrent & "-" & Year(dDate)
& """>" & iCurrent & "
"
    DisplayNongLiDate = ConvertToNongLi(FormatDateTime(Year
(dDate) & "-" & Month(dDate) & "-" & iCurrent ,1))
    Response.Write vbTab & GetNongLiMonthName(DisplayNongLiDate)
& "月" & GetNongLiDayName(DisplayNongLiDate) & "

If iPosition <> 1 Then
  Do While iPosition <= 7
    Response.Write vbTab & vbTab & "

" & vbCrLf
    iPosition = iPosition + 1
  Loop
  Response.Write vbTab & "" & vbCrLf
End If
%>







  一月
  二月
  三月
  四月
  五月
  六月
  七月
  八月
  九月
  十月
  十一月
  十二月


  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31


  1990
  1991
  1992
  1993
  1994
  1995
  1996
  1997
  1998
  1999
  2000
  2001
  2002
  2003
  2004
  2005
  2006
  2007
  2008
  2009
  2010





 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-124758/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10294527/viewspace-124758/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值