.asp当前的月份日历会按照服务器的日期显示当前的月份,突出一下当前日期。参数被设置来定义当前月份的日期数,一个月的第一天的值和被创建的循环是用来显示前一个月的工作日期间的有空白的第一周。第二个循环填补了这个月剩下的时间,插入新月份的开始的工作日的空白。一个简单的同义反复被放在以黑体字放在当前的日期的每个循环里面。逻辑也适用于阳历的某一个二月正确的日期数。
'创建数组来显示月份名称
'创建当前日期的变量
current_date=date()
'创建来自当前日期年份变量
current_year=year(current_date)
'创建来自当前日期年份变量
this_date=day(current_date)
'创建来自当前日期年份变量
month_number=month(current_date)
'创建当前日期的首日变量
first_day=weekday(dateSerial(current_year,month_number,01))
'创建当前月份的长度变量
select case month_number
'有31天的一个月被设置最终日期
case "1","3","5","7","8","10","12"
last_day=31
'通过适用闰年规则把二月设置成最终日期
‘如果年份不能看见
'所有剩下的月份都有30天
case else
last_day=30
end select ' end selct of month
%><html>
<body bgcolor="#FFFFFF">
<table border=1 align=center>
<caption><b><%= month_name(month_number) & current_year %></b></caption>
<tr><th>S</th><th>M</th><th>T</th><th>W</th>
<th>Th</th><th>F</th><th>Sa</th></tr>
<tr>
<%
'循环每个月的第一周
for counter = 1 to 7 %>
<td><%
'检查看看第一个月是哪一天
if counter > first_day-1 then
'计算天数
days=days+1
‘检查看看当前日期是否在第一周
‘然后设置成黑体
'一个月的剩下的周数循环
for weeks = 1 to 5 %>
<tr>
<%
'一个月的剩下的天数的循环
for counter = 1 to 7
'计算出时间
days=days+1
'写出日期,如果是当前日期的话就设置成黑体
<html>
<title>Current Month Calendar</title>
<body bgcolor="#FFFFFF">
<%
dim current_date, first_day, this_date
dim counter,days, weeks, current_year
'创建数组来显示月份名称
dim month_name(12)
month_name(1)="January "
month_name(2)="February "
month_name(3)="March "
month_name(4)="April "
month_name(5)="May "
month_name(6)="June "
month_name(7)="July "
month_name(8)="August "
month_name(9)="September "
month_name(10)="October "
month_name(11)="November "
month_name(12)="December "
'创建当前日期的变量
current_date=date()
'创建来自当前日期年份变量
current_year=year(current_date)
'创建来自当前日期年份变量
this_date=day(current_date)
'创建来自当前日期年份变量
month_number=month(current_date)
'创建当前日期的首日变量
first_day=weekday(dateSerial(current_year,month_number,01))
'创建当前月份的长度变量
select case month_number
'有31天的一个月被设置最终日期
case "1","3","5","7","8","10","12"
last_day=31
'通过适用闰年规则把二月设置成最终日期
‘如果年份不能看见
case "2"
last_day=28
right_year_divided=current_year/4
if right_year_divided = cint(right_year_divided) then
last_day=29
end if
if right(current_year,2)="00" then
right_year_divided=current_year/400
if right_year_divided = cint(right_year_divided) then
last_day=29
end if ' end check of year values
end if ' end check for new century
'所有剩下的月份都有30天
case else
last_day=30
end select ' end selct of month
%><html>
<body bgcolor="#FFFFFF">
<table border=1 align=center>
<caption><b><%= month_name(month_number) & current_year %></b></caption>
<tr><th>S</th><th>M</th><th>T</th><th>W</th>
<th>Th</th><th>F</th><th>Sa</th></tr>
<tr>
<%
'循环每个月的第一周
for counter = 1 to 7 %>
<td><%
'检查看看第一个月是哪一天
if counter > first_day-1 then
'计算天数
days=days+1
‘检查看看当前日期是否在第一周
‘然后设置成黑体
if days=this_date then
response.write "<b>" & days & "</b>"
else
response.write days
end if ' End check for current date
end if ' End check for first day of the week
%></td><%
next %>
</tr>
<%
'一个月的剩下的周数循环
for weeks = 1 to 5 %>
<tr>
<%
'一个月的剩下的天数的循环
for counter = 1 to 7
'计算出时间
days=days+1
'写出日期,如果是当前日期的话就设置成黑体
if days <= last_day then
%><td><%
if days=this_date then
response.write "<b>" & days & "</b>"
else
response.write days
end if ' End check for current date
%></td>
<% end if ' End check for end of month
next %>
</tr><%
next %>
</table>
</body>
</html>
简单生活,希望对大家有用!要觉得本文有价值请分享给您的朋友,生活就是人来人往,分享越多!收获越多!作者:天天ASP家园