<% @LANGUAGE=VBScript %>
<% Option Explicit
Response.Expires = 0
%>
<HTML>
<HEAD>
<TITLE>ASP kalender</TITLE>
<STYLE TYPE="text/css">
<!--
.today {FONT-WEIGHT: bold;
BACKGROUND-COLOR: #cccccc;}
TABLE {BORDER-RIGHT: 1px solid #000000;
BORDER-BOTTOM: 1px solid #000000;}
SELECT, INPUT, .def {FONT-FAMILY: Arial;
FONT-SIZE: 9pt;}
TD {BORDER-LEFT: 1px solid #000000;
BORDER-TOP: 1px solid #000000;
FONT-FAMILY: Arial;
FONT-SIZE: 9pt;}
.grey {FONT-WEIGHT: bold;
BACKGROUND-COLOR: #e0e0e0;}
-->
</STYLE>
</HEAD>
<BODY CLASS="def">
<%
Dim intMaand, intJaar, intAantalWeken, strEDag, strLDag, intDagenInMaand, strToday
Dim aDagNamen
Dim t1, t2, tdag, tweek
Function addLeadingZero(value)
'pre: value is an integer value
'return: the value, converted to a string, with a leading zero if
' the original value is smaller than 10
If value < 10 Then
value = "0" & CStr(value)
Else
value = CStr(value)
End If
addLeadingZero = value
End Function
aDagNamen = Array("Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo")
strToday = Date()
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("action") = "submit" Then
'bovenste formulier
intMaand = CInt(Request.Form("month"))
intJaar = CInt(Request.Form("year"))
If Request.Form("action") = "previous" Then
'previous-knop; haal waarden op
intMaand = CInt(Request.Form("m"))
intJaar = CInt(Request.Form("y"))
'verlaag met 1 maand
If intMaand > 1 Then
intMaand = intMaand - 1
Else
intMaand = 12
intJaar = intJaar - 1
If Request.Form("action") = "next" Then
'next-knop; haal waarden op
intMaand = CInt(Request.Form("m"))
intJaar = CInt(Request.Form("y"))
'verhoog met 1 maand
If intMaand < 12 Then
intMaand = intMaand + 1
Else
intMaand = 1
intJaar = intJaar + 1
Else
'niets ingevuld, pak datum van vandaag
intMaand = DatePart("m", strToday)
intJaar = DatePart("yyyy", strToday)
End If
'Bepaal eerste dag van de huidige maand
strEDag = CDate("1-" & intMaand & "-" &intJaar)
'Bepaal het aantal dagen in deze maand
intDagenInMaand = DateDiff("d", strEDag, DateAdd("m", 1, strEDag))
'Bepaal de laatste dag van deze maand
strLDag = CDate(intDagenInMaand & "-" & intMaand & "-" & intJaar)
'Bepaal het aantal jaarweken waarin deze maand zit
intAantalWeken = DatePart("ww", strLDag, vbMonday) - DatePart("ww", strEDag, vbMonday) + 1
Response.Write "Eerste dag van de maand: " & FormatDateTime(strEDag, vbLongDate) & "<BR>" & vbLf
Response.Write "Laatste dag van de maand: " & FormatDateTime(strLDag, vbLongDate) & "<BR>" & vbLf
%>
<FORM ACTION="<%= Request.ServerVariables("SCRIPT_NAME") %>" METHOD="post">
<SELECT NAME="month">
<%
For t1=1 To 12
Response.Write "<OPTION VALUE=""" & t1 & """"
If t1 = intMaand Then Response.Write " SELECTED" End If
Response.Write ">" & MonthName(t1) & "</OPTION>" & VBLf
Next
%>
</SELECT>
<SELECT NAME="year">
<%
For t1=1995 To 2015
Response.Write "<OPTION VALUE=""" & t1 & """"
If t1 = intJaar Then Response.Write " SELECTED" End If
Response.Write ">" & t1 & "</OPTION>" & VBLf
Next
%>
</SELECT>
<INPUT TYPE="submit" NAME="action" VALUE="submit">
</FORM>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR><TD COLSPAN="<%= (intAantalWeken+1) %>" ALIGN="center"><B><%= MonthName(intMaand) & " " & intJaar %></B></TD></TR>
<%
Response.Write "<TR>" & VBLf
Response.Write "<TD> </TD>" 'extra veld voor dagen-kolom
For t1 = 0 To intAantalWeken-1
tweek = DatePart("ww", strEDag, vbMonday) + t1
Response.Write "<TD CLASS=""grey"">"
If tweek > 52 Then
Response.Write " "
Else
Response.Write addLeadingZero(tweek)
Response.Write "</TD>" & VBLf
Response.Write "</TR>"& VBLf
For t2 = 1 to 7
Response.Write "<TR>" & VBLf
Response.Write "<TD CLASS=""grey"" ALIGN=""center"">" & aDagNamen(t2-1) & "</td>" & VBLf
For t1 = 0 To intAantalWeken-1
tdag = t1*7+t2 - WeekDay(strEDag, vbMonday) + 1
Response.Write "<TD"
If tdag >=1 And tdag <= intDagenInMaand Then
If DateValue(tdag & "-" & intMaand & "-" & intJaar) = strToday Then
Response.Write " CLASS=""today"""
Response.Write ">"
If tdag < 1 Or tdag > intDagenInMaand Then
Response.Write " "
Else
Response.Write addLeadingZero(tdag)
Response.Write "</TD>" & VBLf
Response.Write "</TR>" & VBLf
Next 't2
%>
</TABLE>
<FORM ACTION="<%= Request.ServerVariables("SCRIPT_NAME") %>" METHOD="post">
<INPUT TYPE="hidden" NAME="m" VALUE="<%= intMaand %>">
<INPUT TYPE="hidden" NAME="y" VALUE="<%= intJaar %>">
<INPUT TYPE="submit" NAME="action" VALUE="previous">
<INPUT TYPE="submit" NAME="action" VALUE="next">
</FORM>
</BODY>
</HTML>