📄 calendar.asp
字号:
<%
Dim MyMonth 'Month of calendar
Dim MyYear 'Year of calendar
Dim FirstDay 'First day of the month. 0 = Sunday
Dim CurrentDay 'Used to print dates in calendar
Dim Col 'Calendar column
Dim Row 'Calendar row
MyMonth = cint(Request.Querystring("Month"))
MyYear = cint(Request.Querystring("Year"))
If MyMonth = 0 then MyMonth = Month(Date)
if MyYear = 0 then MyYear = Year(Date)
Call ShowHeader (MyMonth, MyYear)
FirstDay = WeekDay(DateSerial(MyYear, MyMonth, 1)) -1
CurrentDay = 1
'Let's build the calendar
For Row = 0 to 5
For Col = 0 to 6
If Row = 0 and Col < FirstDay then
response.write "<td> </td>"
elseif CurrentDay > LastDay(MyMonth, MyYear) then
response.write "<td> </td>"
else
response.write "<td"
if MyMonth = Month(Date) and CurrentDay = Day(Date) then
response.write " bgcolor='#e6d2f4' align='center' class='blogEntry'>"
else
response.write " align='center'>"
end if
%>
<a href="index.asp?view=archive&day=<%=CurrentDay%>&month=<%=MyMonth%>&year=<%=MyYear%>"><%=CurrentDay%></a></td>
<%
'response.write CurrentDay & "</td>"
CurrentDay = CurrentDay + 1
End If
Next
response.write "</tr>"
Next
response.write "</table>"
'------ Sub and functions
Sub ShowHeader(MyMonth,MyYear)
%>
<table border='0' cellspacing='0' cellpadding='2' width='200' align='center' class="calendar">
<tr align='center'>
<td colspan='7'>
<table border='0' cellspacing='1' cellpadding='1' width='100%' class="calendar">
<tr>
<td align='left' class="calendar">
<%
response.write "<a href = 'index.asp?view="&Request.QueryString("view")&"&day="&Request.QueryString("day")&"&"
if MyMonth - 1 = 0 then
response.write "month=12&year=" & MyYear -1
else
response.write "month=" & MyMonth - 1 & "&year=" & MyYear
end if
response.write "' class='calendar'><</a>"
%>
</td><td align='center' class="calendar">
<a href="index.asp?view=archiveMonth&month=<%=MyMonth%>&year=<%=MyYear%>"><%=MonthName(MyMonth)%> <%=MyYear%></a>
</td><td align='right' class="calendar">
<%
response.write "<a href = 'index.asp?view="&Request.QueryString("view")&"&day="&Request.QueryString("day")&"&"
if MyMonth + 1 = 13 then
response.write "month=1&year=" & MyYear + 1
else
response.write "month=" & MyMonth + 1 & "&year=" & MyYear
end if
response.write "' class='calendar'>></a>"
%>
</td></tr></table>
</td>
</tr>
<tr align='center' class="calendar">
<td><b><i>S</i></b></td>
<td><b><i>M</i></b></td>
<td><b><i>T</i></b></td>
<td><b><i>W</i></b></td>
<td><b><i>T</i></b></td>
<td><b><i>F</i></b></td>
<td><b><i>S</i></b></td>
</tr>
<%
End Sub
Function MonthName(MyMonth)
Select Case MyMonth
Case 1
MonthName = "January"
Case 2
MonthName = "Febuary"
Case 3
MonthName = "March"
Case 4
MonthName = "April"
Case 5
MonthName = "May"
Case 6
MonthName = "June"
Case 7
MonthName = "July"
Case 8
MonthName = "August"
Case 9
MonthName = "September"
Case 10
MonthName = "October"
Case 11
MonthName = "November"
Case 12
MonthName = "December"
Case Else
MonthName = "ERROR!"
End Select
End Function
Function LastDay(MyMonth, MyYear)
' Returns the last day of the month. Takes into account leap years
' Usage: LastDay(Month, Year)
' Example: LastDay(12,2000) or LastDay(12) or Lastday
Select Case MyMonth
Case 1, 3, 5, 7, 8, 10, 12
LastDay = 31
Case 4, 6, 9, 11
LastDay = 30
Case 2
If IsDate(MyYear & "-" & MyMonth & "-" & "29") Then LastDay = 29 Else LastDay = 28
Case Else
LastDay = 0
End Select
End Function
%>
<center><a href="index.asp?view=archiveMonth&month=<%=month(now)%>&year=<%=year(now)%>">当前月份</a></center>
<br>
<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -