<%
Dim arrMonth(31,2) ' Array holding info on each day of the display month
Dim dtDisplayDate ' Date currently displaying calendar for
Dim intDIM ' Days In Current Month
Dim intDOW ' Day Of Week that current month starts on
Dim intCurrentDOM ' Variable we use to hold current day of month as we write table
Dim intCurrentPos ' Variable we use to hold current position in table
Dim testdate1 ' First day of month in long form
Dim testdate2 ' Last day of month in long form
Dim tablecolour
Dim bookedColour
Dim tableBorderColour
Dim tableGapColour
Dim tableHeadingColour
Dim tableTitleColour
Dim tableDayColour
Dim tableFontFace
Dim tableFontSize
Dim tableBodyFontFace
Dim tableBodyFontSize
tablecolour="0000ee"
bookedColour="eeeeee"
tableBorderColour="000000"
tableGapColour="cccccc"
tableHeadingColour="dddddd"
tableTitleColour="cccccc"
tableDayColour="00ff00"
tableFontFace="Arial"
tableFontSize="2"
tableBodyFontFace="Arial"
tableBodyFontSize="2"
Dim startDay
Dim startMonth
Dim startYear
Dim endDay
Dim endMonth
Dim endYear
Dim calendarDay
Dim calendarMonth
Dim calendarYear
%>
<%
' ***Begin Function Declaration***
Function ukDate(str)
'Convert date to unambiguous UK format
Dim aDay
Dim aMonth
Dim aYear
aDay = Day(str)
aMonth = Monthname(Month(str),False)
aYear = Year(str)
ukDate = aDay & "-" & aMonth & "-" & aYear
End Function
Function FindDaysInMonth(iMonth, iYear)
Dim dTemp
dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
FindDaysInMonth = Day(dTemp)
End Function
Function FindStartingWeekdayForMonth(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
FindStartingWeekdayForMonth = WeekDay(dTemp)
End Function
Function DecrementMonth(dtDisplayDate)
DecrementMonth = ukdate(DateAdd("m", -1, dtDisplayDate))
End Function
Function DecrementYear(dtDisplayDate)
DecrementYear = ukdate(DateAdd("yyyy", -1, dtDisplayDate))
End Function
Function IncrementMonth(dtDisplayDate)
IncrementMonth = ukdate(DateAdd("m", 1, dtDisplayDate))
End Function
Function IncrementYear(dtDisplayDate)
IncrementYear = ukdate(DateAdd("yyyy", 1, dtDisplayDate))
End Function
' ***End Function Declaration***
' Get display date by querystring or by current date
If IsDate(Request.QueryString("date")) Then
dtDisplayDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Then
dtDisplayDate = CDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year"))
Else
dtDisplayDate = ukdate(Date())
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.
"
End If
End If
End If
'Find days in the choosen month and the day of the week it starts on.
intDIM = FindDaysInMonth(Month(dtDisplayDate), Year(dtDisplayDate))
intDOW = FindStartingWeekdayForMonth(dtDisplayDate)
'Get first day and last day of month
testdate1="01" & "/" & Monthname(Month(dtDisplayDate)) & "/" & Year(dtDisplayDate)
testdate1=cDate(testdate1)
testdate1=ukdate(testdate1)
testdate2=intDIM & "/" & Monthname(Month(dtDisplayDate)) & "/" & Year(dtDisplayDate)
testdate2=cDate(testdate2)
testdate2=ukdate(testdate2)
'Retrieve all values from configuration table
%>
<%
' Write spacer cells at beginning of first row if month doesn't start on a Sunday.
If intDOW <> 1 Then
Response.Write vbTab & "
" & vbCrLf
intCurrentPos = 1
Do While intCurrentPos < intDOW
Response.Write vbTab & vbTab & "
" & vbCrLf
intCurrentPos = intCurrentPos + 1
Loop
End If
' Write days of month in proper day slots
intCurrentDOM = 1
intCurrentPos = intDOW
Do While intCurrentDOM <= intDIM
' If we're at the beginning of a row then write TR
If intCurrentPos = 1 Then
Response.Write vbTab & "
" & vbCrLf
End If
' Write the date into the cell.
Response.Write vbTab & vbTab & "
" & vbCrLf
' If at the end of a row then write /TR
If intCurrentPos = 7 Then
Response.Write vbTab & "
" & vbCrLf
intCurrentPos = 0
End If
' Increment variables
intCurrentDOM = intCurrentDOM + 1
intCurrentPos = intCurrentPos + 1
Loop
' Write spacer cells at end of last row if month doesn't end on a Saturday.
If intCurrentPos <> 1 Then
Do While intCurrentPos <= 7
Response.Write vbTab & vbTab & "
" & vbCrLf
intCurrentPos = intCurrentPos + 1
Loop
Response.Write vbTab & "" & vbCrLf
End If
%>