Kalender -skal starte mandag!
HejEfter at have været i gennem næsten samtlige indlæg her vedr. kalendere uden at finde en løsning på mit problem, kommer det her som spørgsmål:
Jeg har fundet en ganske smart kalender med mulighed for at oprette og slette begivenheder - bruge den som privat eller offentlig kalender osv. Det hele fungerer fint bortset fra et lille, men meget irriterende problem: Kalenderen starter ugen på en søndag, som i USA og ikke på en mandag, som vi gør her i europa. Betyder også at den skriver forkerte ugenumre. Kalenderen består af flere filer hvoraf den vigtigste er default.asp som ser sådan ud:
<%@ language="VBScript" LCID=1030 %>
<%
strELID = Session("ELID")
If strELID = "" Then
strMsg = "<div onClick=""document.location.href='calLogin.asp'; "" style=""cursor:hand;"" onMouseOver=""this.style.color='Green';"" onMouseOut=""this.style.color='';"">LOG IND</div>"
Else
strMsg = "<div onClick=""document.location.href='calLogout.asp'; "" style=""cursor:hand;"" onMouseOver=""this.style.color='Green';"" onMouseOut=""this.style.color='';"">" & strELID & " LOG UD</div>"
End if
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.CursorLocation = Application("dbCursorLocation")
dbConn.Open Application("dbString")
SelectedDate = Request.QueryString("SelectedDate")
CurrentDate = FormatDateTime(Now(),2)
If SelectedDate = "" Then SelectedDate = CurrentDate
%>
<html>
<head>
<title>Foreningens kalender</title>
<link rel="STYLESHEET" type="text/css" href="calStyle.css">
<script language="JavaScript">
function changeDate(newDate)
{
document.location.href = 'calList.asp?SelectedDate=' + newDate;
}
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin=10 topmargin=10>
<!-- #include file = "Header.htm" -->
<table width="100%" height="85%" border="0" cellspacing="1" cellpadding="3">
<tr valign="top">
<td valign="bottom" class="Nav" nowrap height="25" align="left" onClick="document.location.href='Default.asp?SelectedDate=<%=DateAdd("m",-1,SelectedDate)%>';">
<< Forrige måned
</td>
<th height="25" width="100%" class="MonthYear">
<%
If DateDiff("d",SelectedDate,CurrentDate) = 0 Then
Response.Write WeekDayName(WeekDay(SelectedDate)) & ", " & Day(SelectedDate) & " " & MonthName(Month(SelectedDate)) & ", " & Year(SelectedDate)
Else
Response.Write MonthName(Month(SelectedDate)) & ", " & Year(SelectedDate)
End If
%>
</th>
<td valign="bottom" class="Nav" nowrap height="25" align="right" onClick="document.location.href='Default.asp?SelectedDate=<%=DateAdd("m",1,SelectedDate)%>';">
Næste måned >>
</td>
</tr>
<tr height="100%">
<td colspan=3>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="3" style="border: 1px solid #DCDCDC;">
<tr height="1%" class="WeekDay">
<td style="background-color: #008000" bordercolor="#DCDCDC"> </td>
<td width="14%" style="background-color: #008000" bordercolor="#DCDCDC">Søndag</td>
<td width="14%" style="background-color: #008000" bordercolor="#DCDCDC">Mandag</td>
<td width="14%" style="background-color: #008000" bordercolor="#DCDCDC">Tirsdag</td>
<td width="14%" style="background-color: #008000" bordercolor="#DCDCDC">Onsdag</td>
<td width="14%" style="background-color: #008000" bordercolor="#DCDCDC">Torsdag</td>
<td width="14%" style="background-color: #008000" bordercolor="#DCDCDC">Fredag</td>
<td width="14%" style="background-color: #008000" bordercolor="#DCDCDC">Lørdag</td>
</tr>
<tr>
<%
mDate = DateSerial(Year(SelectedDate),Month(SelectedDate),1)
fDate = DateSerial(Year(SelectedDate),1,1)
Response.Write "<td class=""WeekNum"">" & DateDiff("ww",mDate,fDate) & "</td>"
For nDex = 1 to Weekday(mDate) -1
Response.Write "<td class=""EmptyDays""> </td>"
Next
While (Month(mDate) = Month(SelectedDate))
If DateDiff("d",mDate,CurrentDate) = 0 Then
strClass = "CurDay"
Else
strClass = "Days"
End If
Set dbRS = dbConn.Execute("SELECT * FROM EVENTS WHERE EDATE = FORMAT('" & mDate & "','MM/DD/YYYY')")
If NOT dbRS.EOF Then
Response.Write "<td valign=""top"" class=""" & strClass & """ onClick=""changeDate('" & mDate & "');"" onMouseOver=""window.status='" & WeekDayName(WeekDay(mDate)) & ", " & MonthName(Month(mDate)) & " " & Day(mDate) & ", " & Year(mDate) & "';"" onMouseOut=""window.status='';"">"
Response.Write Day(mDate)
While NOT dbRS.EOF
If dbRS.Fields("EPUBLIC").Value = True OR dbRS.Fields("ELID").Value = strELID Then
Response.Write "<div title=""" & dbRS.Fields("ELID").Value & """ class=""" & dbRS.Fields("ECLASS").Value & """>" & dbRS.Fields("EVENT").Value & "<div>"
End If
dbRS.MoveNext
Wend
Else
Response.Write "<td valign=""top"" class=""" & strClass & """ onClick=""changeDate('" & mDate & "');"" onMouseOver=""window.status='" & WeekDayName(WeekDay(mDate)) & ", " & Day(mDate) & " " & MonthName(Month(mDate)) & ", " & Year(mDate) & "';"" onMouseOut=""window.status='';"">" & Day(mDate) & "<div class=""EventBlank""> </div>"
End If
Response.Write "</td>"
If WeekDay(mDate) = 7 Then
Response.Write "</tr>"
End If
mDate = DateAdd("d", 1, mDate)
If WeekDay(mDate) = 1 AND (Month(mDate) = Month(SelectedDate)) Then
Response.Write "<tr><td class=""WeekNum"">" & DateDiff("ww",fDate,mDate) & "</td>"
End If
Wend
If Weekday(mDate) <> 1 Then
For nDex = Weekday(mDate) to 7
Response.Write "<td class=""EmptyDays""> </td>"
Next
End If
%>
</tr>
</table>
</td>
</tr>
<tr class="Today">
<td align="left"><%=strMsg%></td>
<td colspan="2" align="right" nowrap>
I dag: <%=WeekDayName(WeekDay(CurrentDate)) & ", " & Day(CurrentDate) & " " & MonthName(Month(CurrentDate)) & ", " & Year(CurrentDate)%>
</td>
</tr>
</table>
</body>
</html>
Hele filkomplekset med database kan hentes på: http://www.ab-nymarksvej.dk/zip-filer/kalender.zip
200 points til ham der kommer med en brugbar løsning.
Mvh. Stefcor
