% @LANGUAGE = VBScript %>
<% Option Explicit %>
<% REM This is Javascript2-4.htm converted to ASP %>
Calendar for <%
Dim year
year = Request.QueryString("year")
Response.write(year)
%>
<% Response.write(year) %>
<%
REM Need an array which tells us how many days are in each month
Dim daysinmonth(12)
daysinmonth(1) = 31
daysinmonth(2) = 28
daysinmonth(3) = 31
daysinmonth(4) = 30
daysinmonth(5) = 31
daysinmonth(6) = 30
daysinmonth(7) = 31
daysinmonth(8) = 31
daysinmonth(9) = 30
daysinmonth(10) = 31
daysinmonth(11) = 30
daysinmonth(12) = 31
REM Need an array of month names
Dim months(12)
months(1) = "January"
months(2) = "February"
months(3) = "March"
months(4) = "April"
months(5) = "May"
months(6) = "June"
months(7) = "July"
months(8) = "August"
months(9) = "September"
months(10) = "October"
months(11) = "November"
months(12) = "December"
REM Need a date variable so we can do calculations
Dim calyear
REM Determine if the year wanted is a leap year
Dim leap_year
leap_year = False
If year Mod 4 = 0 Then
leap_year = True
If (year Mod 100 = 0) And (year Mod 400 <> 0) Then
leap_year = False
End If
End If
REM February is an exception due to leap year. If the year is
REM divisible by 4, then it's a leap year.
If leap_year Then
daysinmonth(2)=29
End If
REM Create an HTML table for each month
REM Set some variables to get started
Dim i
Dim j
Dim writearow
Dim weekstartday
Dim monthendday
For i = 1 to 12 ' January=1, December=12 etc.
Response.write("" & months(i) & "
" & vbCrLf)
REM Set the date to the start of the current month
calyear = DateValue(i & "/01/" & year)
Response.write("" & vbCrLf)
REM Write day of week information in first row of each month table
Response.write("" & vbCrLf)
Response.write("| Sunday | " & vbCrLf)
Response.write("Monday | " & vbCrLf)
Response.write("Tuesday | " & vbCrLf)
Response.write("Wednesday | " & vbCrLf)
Response.write("Thursday | " & vbCrLf)
Response.write("Friday | " & vbCrLf)
Response.write("Saturday | " & vbCrLf)
Response.write("
" & vbCrLf)
writearow = True
weekstartday = DatePart("d", calyear) - DatePart("w", calyear)
monthendday = daysinmonth(i)
REM Response.write(weekstartday & "
" & vbCrLf)
While writearow
REM Write one week of the calendar
Response.write("" & vbCrLf)
For j = 1 to 7
If ((weekstartday+j) < 1) Or ((weekstartday+j)>monthendday) Then
Response.write(" | " & vbCrLf) ' Write a blank date
Else
Response.write("" & (weekstartday+j) & " | " & vbCrLf)
End If
Next
Response.write("
" & vbCrLf)
REM Figure out if we've displayed the last week for the current month
If (weekstartday+j) > monthendday Then
writearow = False
Else
weekstartday = weekstartday + 7
End If
Wend
Response.write("
" & vbCrLf)
Next
%>