|
在网上找了很久的万年历程序,基本上都是用JScript写的,
昨天终于让我找到了个用纯ASP写的,帖出来分享一下:
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
<%
y=request.querystring("y")
m=request.querystring("m")
d=request.querystring("d")
if y="" then
y=year(date)
m=month(date)
d=day(date)
end if
call blogdate(y,m,d)
'=====================以年月日为参数的显示==============================================
sub blogdate(y,m,d) '
str1=" 当前的日期是"&y&"年"&m&"月"&d&"日 " '得到当前日期的年月日
nowdate=y&"-"&m&"-"&d
lastdate=dateadd("m",-1,nowdate)
lasty=year(lastdate)
lastm=month(lastdate)
nextdate=dateadd("m",1,nowdate)
nexty=year(nextdate)
nextm=month(nextdate)
str1=str1&"<a href="&request.servervariables("path_info")&"?y="&lasty&"&m="&lastm&"&d=1"&">上一月</a> "
str1=str1&"<a href="&request.servervariables("path_info")&"?y="&nexty&"&m="&nextm&"&d=1"&">下一月</a> "
str1=str1&"<a href="&request.servervariables("path_info")&">返回今日</a>"
response.write str1
thismonth=y&"-"&m&"-1" '当前月的第一天
nextmonth=dateadd("m",1,thismonth) '下个月的第一天
num=datediff("d",thismonth,nextmonth) '当前月的天数
firstday=weekday(thismonth)-1 '得到当前月第一天的星期
'call displaydate(firstday,num)
Response.Write "<table border=1 width=""40%"" style=""border-collapse:collapse"">" & vbCrlf
Response.Write "<tr>" & vbCrlf
Response.Write "<td align=""center"">星期日</td>" & vbCrlf
Response.Write "<td align=""center"">星期一</td>" & vbCrlf
Response.Write "<td align=""center"">星期二</td>" & vbCrlf
Response.Write "<td align=""center"">星期三</td>" & vbCrlf
Response.Write "<td align=""center"">星期四</td>" & vbCrlf
Response.Write "<td align=""center"">星期五</td>" & vbCrlf
Response.Write "<td align=""center"">星期六</td>" & vbCrlf
Response.Write "</tr>" & vbCrlf
'需要参数:当前月第一天的星期firstday,当前月的天数num
for n=1 to 6
response.write "<tr>"
for i=1 to 7
thisday=0
if i>firstday then thisday=i-firstday
if n>1 then thisday=7*(n-1)+i-firstday
if thisday>num then thisday=0
if thisday=0 then
display=" "
else
display="<a href="&request.servervariables("path_info")&"?y="&y&"&m="&m&"&d="&thisday&">"&thisday&"</a>"
end if
response.write "<td align=""center"">"&display&"</td>"
next
if n=5 and (thisday=num or thisday=0) then n=n+1
response.write "</tr>"
next
Response.Write "</table>" & vbCrlf
end sub
'===================================================================
%> |
|