Kalender viser forkerte ugedage
Jeg er i gang med at lave en hjemmeside og har i den forbindelse fået sat en kalender ind, men jeg opdagede lige at lige så snart man skifter måned f.eks til februar vises datoerne ikke under de rigtige ugedage.Den direkte url til siden er: www.marstalsejlklub.dk/kalender.asp.
Håber der er nogen der kan forklare mig hvad problemet er.
Sourcecode:
<%@ LANGUAGE=VBScript %>
<!--#INCLUDE FILE="adovbs.asp"-->
<!--#INCLUDE FILE="objadodb.asp"-->
<%
Dim Resul,SQL,link
' ------------------------------------------------------------------------------------
' Link til side med nærmere beskrivelse
'-------------------------------------------------------------------------------------
link = "events.htm"
SQL = " SELECT * FROM kalender "
SET Resul = database.execute(SQL)
%><%
Function GetDaysInMonth(iMonth, iYear)
Select Case iMonth
Case 1, 3, 5, 7, 8, 10, 12
GetDaysInMonth = 31
Case 4, 6, 9, 11
GetDaysInMonth = 30
Case 2
If IsDate("February 29, " & iYear) Then
GetDaysInMonth = 29
Else
GetDaysInMonth = 28
End If
End Select
End Function
Function GetWeekdayMonthStartsOn(iMonth, iYear)
GetWeekdayMonthStartsOn = WeekDay(CDate(iMonth & "/1/" & iYear))
End Function
Function SubtractOneMonth(dDate)
Dim iDay, iMonth, iYear
iDay = Day(dDate)
iMonth = Month(dDate)
iYear = Year(dDate)
If iMonth = 1 Then
iMonth = 12
iYear = iYear - 1
Else
iMonth = iMonth - 1
End If
If iDay > GetDaysInMonth(iMonth, iYear) Then iDay = GetDaysInMonth(iMonth, iYear)
SubtractOneMonth = CDate(iMonth & "-" & iDay & "-" & iYear)
End Function
Function AddOneMonth(dDate)
Dim iDay, iMonth, iYear
iDay = Day(dDate)
iMonth = Month(dDate)
iYear = Year(dDate)
If iMonth = 12 Then
iMonth = 1
iYear = iYear + 1
Else
iMonth = iMonth + 1
End If
If iDay > GetDaysInMonth(iMonth, iYear) Then iDay = GetDaysInMonth(iMonth, iYear)
AddOneMonth = CDate(iMonth & "-" & iDay & "-" & iYear)
End Function
Function FormatMonthName(dMonth)
If dMonth = 1 Then FormatMonthName = "Januar"
If dMonth = 2 Then FormatMonthName = "Februar"
If dMonth = 3 Then FormatMonthName = "Marts"
If dMonth = 4 Then FormatMonthName = "April"
If dMonth = 5 Then FormatMonthName = "Maj"
If dMonth = 6 Then FormatMonthName = "Juni"
If dMonth = 7 Then FormatMonthName = "Juli"
If dMonth = 8 Then FormatMonthName = "August"
If dMonth = 9 Then FormatMonthName = "September"
If dMonth = 10 Then FormatMonthName = "Oktober"
If dMonth = 11 Then FormatMonthName = "November"
If dMonth = 12 Then FormatMonthName = "December"
End Function
Dim dDate ' Date we're displaying calendar for
Dim iDIM ' Days In Month
Dim iDOW ' Day Of Week that month starts on
Dim iCurrent ' Variable we use to hold current day of month as we write table
Dim iPosition ' Variable we use to hold current position in table
If IsDate(Request.QueryString("date")) Then
dDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Then
dDate = CDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year"))
Else
dDate = Date()
End If
End If
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(Month(dDate), Year(dDate))
%>
<html>
<!-- #BeginTemplate "index.htt" -->
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive 6">
<title>Marstal Sejlklub</title>
<link href="style.css" rel="stylesheet" media="screen">
<SCRIPT type=text/javascript src="menu.js"></SCRIPT>
<!-- #BeginHeadLocked "" -->
<link href="style.css" rel="stylesheet" media="screen">
<SCRIPT type=text/javascript src="menu.js"></SCRIPT>
<!-- #EndHeadLocked -->
</head>
<body bgcolor="#0d004c" onload="visMenu('menu6',true)">
<table width="790" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3"><img src="top6.jpg" alt="" height="225" width="790" border="0"></td>
</tr>
<tr>
<td align="center" valign="top" width="241">
<table class="border" width="241" border="0" cellspacing="0" cellpadding="0" height="450">
<tr>
<td rowspan="3" width="10"></td>
<td rowspan="3" colspan="2" align="left" valign="top">
<DIV id=leftcol>
<DIV id=mainMenu>
<UL id=menuList>
<LI class=menubar><A href="index.html">Startsiden</A>
<UL class=menu id=menu1>
<LI><A href="aftenkap.html">Aftenkapsejlads</A>
<LI><A href="kontakt.html">Kontakt</A>
</UL>
</LI>
<LI class=menubar><A href="java script:visMenu('menu2',true)">Ungdomsafdelingen</A>
<UL class=menu id=menu2>
<LI><A href="optimist.html">Optimister</A>
<LI><A href="pirat.html">Piratjoller</A></LI>
</UL>
<LI class=menubar><A href="java script:visMenu('menu3',true)">Udvalg</A>
<UL class=menu id=menu3>
<LI><A href="optimistudv.html">Optimistudvalg</A>
<LI><A href="sejladsudv.html">Sejladsudvalg</A>
<LI><A href="juniorudv.html">Juniorudvalg</A>
<LI><A href="roudv.html">Roudvalg</A>
<LI><A href="klubhusudv.html">Klubhusudvalg</A>
<LI><A href="festudv.html">Festudvalg</A>
<LI><A href="pladsudv.html">Kran/plads udvalg</A>
<LI><A href="haveudv.html">Haveudvalg</A>
<LI><A href="klubmaal.html">Klubmåler</A></LI>
</UL>
<LI class=menubar><A href="ballonindex.asp">Ballonen</A>
<UL class=menu id=menu4>
<LI><A href="ballonen/ballonarkiv.html">Arkiv</A>
</UL>
<LI class=menubar><A href="besty.html">Bestyrelsen</A></LI>
<LI class=menubar><A href="java script:visMenu('menu5',true)">Arrangementer</A>
<UL class=menu id=menu5>
<LI><A href="kalender.asp">Kalender</A></LI>
</UL>
<LI class=menubar><A href="java script:visMenu('menu6',true)">Billeder</A>
<UL class=menu id=menu6>
<LI><A href="billeder/soeg.html">Søg</A></LI>
</UL>
<LI class=menubar><A href="kisten.html">Skibskisten</A>
<UL class=menu id=menu7>
<LI><A href="skibskisten/annoncer.html">Annoncer</A>
<LI><A href="skibskisten/tilfoej.html">Tilføj annonce</A>
<LI><A href="skibskisten/soeg.html">Søg</A></LI>
</UL>
<LI class=menubar><A href="java script:visMenu('menu8',true)">Roafdelingen</A>
<UL class=menu id=menu8>
</LI>
</UL>
<LI class=menubar><A href="java script:visMenu('menu9',true)">Turberetning</A>
<UL class=menu id=menu9>
<LI><A href="turberet/soeg.html">Søg</A></LI>
</UL>
<LI class=menubar><A href="sitemap.html">Sitemap</A></LI>
</LI>
</UL>
</DIV>
</DIV>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</td>
<td colspan="2" align="left" valign="top"><!-- #BeginEditable "Region" -->
<table class="border2" width="549" border="0" cellspacing="0" cellpadding="0" height="450">
<tr>
<td rowspan="3" width="10"></td>
<td rowspan="3" colspan="2" align="center" valign="top"><br>
<table width="90%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td colspan="2"><A HREF="kalender.asp?date=<%= SubtractOneMonth(dDate) %>"><--</A></td>
<td colspan="3" align="center"><span class="broedtext"><%= FormatMonthName(Month(dDate)) & " " & Year(dDate) %></span></td>
<td colspan="2" align="right"><A HREF="kalender.asp?date=<%= AddOneMonth(dDate) %>" style="color: #FFFFFF">--></A></td>
</tr>
<tr>
<td>
<div align="center">
<span class="broedtext">Mandag</span></div>
</td>
<td>
<div align="center">
<span class="broedtext">Tirsdag</span></div>
</td>
<td>
<div align="center">
<span class="broedtext">Onsdag</span></div>
</td>
<td>
<div align="center">
<span class="broedtext">Torsdag</span></div>
</td>
<td>
<div align="center">
<span class="broedtext">Fredag</span></div>
</td>
<td>
<div align="center">
<span class="broedtext">Lørdag</span></div>
</td>
<td>
<div align="center">
<span class="broedtext">Søndag</span></div>
</td>
</tr>
<%
if iDOW = 1 Then iDOW = 8
If iDOW <> 1 Then
Response.Write(vbTab & "<tr>" & vbCrLf)
iPosition = 2
Do While iPosition < iDOW
Response.Write(vbTab & vbTab & "<td> </td>" & vbCrLf)
iPosition = iPosition + 1
Loop
End If
'-- Write days of month in proper day slots --
iCurrent = 1
iPosition = iDOW-1
Do While iCurrent <= iDIM
'-- open the table row --
If iPosition = 1 Then
Response.Write(vbTab & "<tr>" & vbCrLf)
End If
'-- Write the date and subject --
Response.Write(vbTab & vbTab & "<td align=left valign=top height=60 class='kalender' width='11%'><span><b> " & iCurrent & "</b></span>")
resul.movefirst
Do While NOT Resul.EOF
If Resul("Year") = Year(dDate) Then
If Resul("Month") = Month(dDate) Then
If Resul("Day") = iCurrent Then
Response.Write("<br><span class=broedtekst><center>" & resul("overskrift") & "</center></span><br>")
End If
End If
End If
resul.MoveNext
Loop
Response.Write("</td>" & vbCrLf)
'-- Close the table row --
If iPosition = 7 Then
Response.Write vbTab & "</tr>" & vbCrLf
iPosition = 0
End If
'-- Increment variables --
iCurrent = iCurrent + 1
iPosition = iPosition + 1
Loop
If iPosition <> 1 Then
Do While iPosition <= 7
Response.Write(vbTab & vbTab & "<td> </td>" & vbCrLf)
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</table>
</td>
</tr>
<tr></tr>
<tr></tr>
</table>
<!-- #EndEditable --></td>
</tr>
<tr>
<td width="241"></td>
<td width="550"></td>
<td></td>
</tr>
</table>
<p></p>
</body>
<!-- #EndTemplate -->
</html>