ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 使用ASP编写农历算法(二)(转)

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

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-06-01 12:39:05 0 删除 编辑
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)

%>







  
    
  
  
    
    
    
    
    
    
    
  
<%
If iDOW <> 1 Then
  Response.Write vbTab & "" & vbCrLf
  iPosition = 1
  Do While iPosition < iDOW
    Response.Write vbTab & vbTab & "" & vbCrLf
    iPosition = iPosition + 1
  Loop
End If

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

" & vbCrLf
  End If
  
  If iCurrent = Day(dDate) Then
    Response.Write vbTab & vbTab & "" & vbCrLf
  Else
    Response.Write vbTab & vbTab & "" & vbCrLf
  End If
  
  If iPosition = 7 Then
    Response.Write vbTab & "" & vbCrLf
    iPosition = 0
  End If
  
  iCurrent = iCurrent + 1
  iPosition = iPosition + 1
Loop

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

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

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

    
星期
日

BORDER=0>
星期
一

BORDER=0>
星期
二

BORDER=0>
星期
三

BORDER=0>
星期
四

BORDER=0>
星期
五

BORDER=0>
星期
六

BORDER=0>
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) & "











 


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

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    3481
  • 访问量
    3019264