📄 9-1.asp
字号:
<%
'函数申明
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
'每月1日的星期数
Function GetWeekdayMonthStartsOn(iMonth, iYear)
GetWeekdayMonthStartsOn = WeekDay(CDate(iMonth & "/1/" & iYear))
End Function
'减少一月后的日期
Function SubtractOneMonth(dDate)
Dim iDay, iMonth, iYear
iDay = Day(dDate)
iMonth = Month(dDate)
iYear = Year(dDate)
If iMonth = 1 Then
iMonth = 12
iYear = iYear - 1
Else
iMonth = iMonth - 1
End If
If iDay > GetDaysInMonth(iMonth, iYear) Then
iDay = GetDaysInMonth(iMonth, iYear)
end if
SubtractOneMonth = CDate(iYear & "-" &iMonth & "-" &iDay )
End Function
'增加一天后的日期
Function AddOneMonth(dDate)
Dim iDay, iMonth, iYear
iDay = Day(dDate)
iMonth = Month(dDate)
iYear = Year(dDate)
If iMonth = 12 Then
iMonth = 1
iYear = iYear + 1
Else
iMonth = iMonth + 1
End If
If iDay > GetDaysInMonth(iMonth, iYear) Then
iDay = GetDaysInMonth(iMonth, iYear)
end if
AddOneMonth = CDate(iYear & "-" & iMonth & "-" & iDay)
End Function
' ***End Function Declaration***
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("year") & "-" & Request.QueryString("month") & "-" & Request.QueryString("day"))
Else
dDate = Date()
' 在IIS3上运行可能会有些问题
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 "The date you picked was not a valid date. The calendar was set to today's date.<BR><BR>"
End If
'最好是在IIS4上面运行
If Request.QueryString.Count <> 0 Then
Response.Write "The date you picked was not a valid date. The calendar was set to today's date.<BR><BR>"
End If
End If
End if
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(Month(dDate), Year(dDate))
%>
<!—上面为显示精美的表格-->
<TABLE BORDER=10 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 BGCOLOR=#99CCFF>
<TR>
<TD BGCOLOR=#000099 ALIGN="center" COLSPAN=7>
<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD ALIGN="right">
<A HREF="10-1.asp?date=<%= SubtractOneMonth(dDate) %>">
<FONT COLOR=#FFFF00 SIZE="-1"><<</FONT>
</A>
</TD>
<TD ALIGN="center">
<FONT COLOR=#FFFF00><B>
<%= MonthName(Month(dDate)) & " " & Year(dDate) %>
</B>
</FONT>
</TD>
<TD ALIGN="left">
<A HREF="10-1.asp?date=<%= AddOneMonth(dDate) %>">
<FONT COLOR=#FFFF00 SIZE="-1">>>
</FONT>
</A>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="center" BGCOLOR=#0000CC>
<FONT COLOR=#FFFF00><B>
日
</B></FONT>
<BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0>
</TD>
<TD ALIGN="center" BGCOLOR=#0000CC>
<FONT COLOR=#FFFF00>
<B>
一
</B>
</FONT>
<BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0>
</TD>
<TD ALIGN="center" BGCOLOR=#0000CC>
<FONT COLOR=#FFFF00><B>
二
</B>
</FONT>
<BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0>
</TD>
<TD ALIGN="center" BGCOLOR=#0000CC>
<FONT COLOR=#FFFF00><B>
三
</B>
</FONT>
<BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0>
</TD>
<TD ALIGN="center" BGCOLOR=#0000CC>
<FONT COLOR=#FFFF00><B>
四
</B>
</FONT>
<BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0>
</TD>
<TD ALIGN="center" BGCOLOR=#0000CC>
<FONT COLOR=#FFFF00><B>
五
</B>
</FONT>
<BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0>
</TD>
<TD ALIGN="center" BGCOLOR=#0000CC>
<FONT COLOR=#FFFF00><B>
六
</B>
</FONT>
<BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0>
</TD>
</TR>
<%
'输出空白的表格单元如果不是这个月不是以星期天开始
If iDOW <> 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
iPosition = 1
Do While iPosition < iDOW
Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
iPosition = iPosition + 1
Loop
End If
'按一定的顺序具体输出各天
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
If iPosition = 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
End If
'如果这一天是选种的那一天,则高亮显示
If iCurrent = Day(dDate) Then
Response.Write vbTab & vbTab & "<TD BGCOLOR=#00FFFF><FONT SIZE=""-1""><B>" & iCurrent & "</B></FONT><BR><BR></TD>" & vbCrLf
Else
Response.Write vbTab & vbTab & "<TD><A HREF=""10-1.asp?date=" & Year(dDate) & "-" & Month(dDate) & "-" &iCurrent& """><FONT SIZE=""-1"">" & iCurrent & "</FONT></A><BR><BR></TD>" & vbCrLf
End If
'如果到了行尾则输出 /TR
If iPosition = 7 Then
Response.Write vbTab & "</TR>" & vbCrLf
iPosition = 0
End If
'修改变量
iCurrent = iCurrent + 1
iPosition = iPosition + 1
Loop
'如果此月不是一周六结束,则在最后一行后面输出空白单元
If iPosition <> 1 Then
Do While iPosition <= 7
Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</TD>
</TR>
</TABLE>
<form method="get" action="10-1.asp">
年:<select size="1" name="year">
<option>2005</option>
<option>2004</option>
<option>2003</option>
<option>2002</option>
<option>2001</option>
<option>2000</option>
<option>1999</option>
<option>1998</option>
</select>月:<select size="1" name="month">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>日:<select size="1" name="day">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select><br>
<input type="submit" value="显示日期" name="B1"><input type="reset" value="重置" name="B2"></p>
</form>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -