Avatar billede rashid Praktikant
30. juni 2005 - 09:10 Der er 1 kommentar og
1 løsning

ocean12 - kalender script

Jeg kan ikke få den rigtige dato frem for halvdelen af måneden. er der nogen der vil kigge på det ?
prøv en gang at se denne kalender: http://rushy.dk/undersider/calender/default.asp og tryk på eks. den første (juni) - den returnerer 1. januar. klikker man på eks. 14 (juni) får man 14.06.
koden kommer som følger:
<!--#include file="dsn.asp"-->
<!--#include file="body.asp"-->
<html>
<head>
<title><%=RSBODY("Page_Title")%></title>

<!--#include file="style.asp"-->

</head>
<body bgcolor="<%=RSBODY("Background_Color")%>" text="<%=RSBODY("Font_Color")%>" link="<%=RSBODY("Link_Color")%>" vlink="<%=RSBODY("Visited_Link_Color")%>" alink="<%=RSBODY("Active_Link_Color")%>">

<%

navmonth = request.querystring("month")
navyear = request.querystring("year")

If navmonth = "" Then
  navmonth = Month(Date)
End If

If navyear = "" Then
  navyear = Year(Date)
End If

firstday = Weekday(CDate(navmonth & "/" & 1 & "/" & navyear))


leapTestNumbers = navyear / 4
leapTest = (leapTestNumbers) - Round(leapTestNumbers)
If navmonth = 2 Then
  If leapTest <> 0 Then
    lastDate = 28
  Else
    lastDate = 29
  End If
ElseIf ((navmonth = 4) OR (navmonth = 6) OR (navmonth = 9) OR (navmonth = 11)) Then
  lastDate = 30
Else
  lastDate = 31
End If

lastMonth = navmonth - 1
lastYear = navyear
If lastMonth < 1 Then
  lastMonth = 12
  lastYear = lastYear - 1
End If

nextMonth = navmonth + 1
nextYear = navyear
If nextMonth >12 Then
  nextMonth = 1
  nextYear = nextYear + 1
End If


dateCounter = 1
weekCount = 1

DateEnd = lastDate
DateBegin = firstDate

Weekday_Font = RSBODY("Weekday_Font")
Weekday_Font_Size = RSBODY("Weekday_Font_Size")
Weekday_Font_Color = RSBODY("Weekday_Font_Color")
Weekday_Background_Color = RSBODY("Weekday_Background_Color")
Date_Font = RSBODY("Date_Font")
Date_Font_Size = RSBODY("Date_Font_Size")
Date_Font_Color = RSBODY("Date_Font_Color")
Date_Background_Color = RSBODY("Date_Background_Color")
Event_Font = RSBODY("Event_Font")
Event_Font_Size = RSBODY("Event_Font_Size")
Event_Font_Color = RSBODY("Event_Font_Color")
Cell_Width = RSBODY("Cell_Width")
Cell_Height = RSBODY("Cell_Height")
Cell_Background_Color = RSBODY("Cell_Background_Color")
Border_Size = RSBODY("Border_Size")
Border_Color = RSBODY("Border_Color")
%>

<%=RSBODY("Header")%>

<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center">

<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td align="left" valign="bottom"><font face="verdana" size="2"><a href="default.asp?month=<%=lastMonth%>&year=<%=lastYear%>"><%If (RSBODY("Abbreviate_Months") = True) Then%><%=MonthName(lastMonth, true)%><%Else%><%=MonthName(lastMonth)%><%End If%></a></font></td>
<td align="center" valign="bottom"><font face="verdana" size="4"><%If (RSBODY("Abbreviate_Months") = True) Then%><%=MonthName(navMonth, true)%><%Else%><%=MonthName(navMonth)%><%End If%>&nbsp;<%=navyear%></font></td>
<td align="right" valign="bottom"><font face="verdana" size="2"><a href="default.asp?month=<%=nextMonth%>&year=<%=nextYear%>"><%If (RSBODY("Abbreviate_Months") = True) Then%><%=MonthName(nextMonth, true)%><%Else%><%=MonthName(nextMonth)%><%End If%></a></font></td>
</tr>
</table>

</td>
</tr>
<tr>
<td>

<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="<%=Border_Color%>">

<table border="0" cellpadding="2" cellspacing="<%=Border_Size%>">
<tr>
<td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Days") = True) Then%>Sun<%Else%>Sunday<%End If%></font></td>
<td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Days") = True) Then%>Mon<%Else%>Monday<%End If%></font></td>
<td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Days") = True) Then%>Tues<%Else%>Tuessday<%End If%></font></td>
<td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Days") = True) Then%>Wed<%Else%>Wednesday<%End If%></font></td>
<td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Days") = True) Then%>Thurs<%Else%>Thursday<%End If%></font></td>
<td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Days") = True) Then%>Fri<%Else%>Friday<%End If%></font></td>
<td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Days") = True) Then%>Sat<%Else%>Saturday<%End If%></font></td>
</tr>


<tr>
<% Do while weekCount <= 7
dateSelect = navmonth & "/" & dateCounter & "/" & navyear %>

<% If (weekCount < firstDay) OR (dateCounter > lastDate) Then %>
<td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>"><img src="im/clear.gif" height="1" width="1"></td>
<% else %>
<td height="<%=Cell_Height%>" bgcolor="<%=Date_Background_Color%>" valign="top"><a href="date.asp?date=<%=dateSelect%>"><font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><%=dateCounter%></font><font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">

<%
Set RSEVENT = Server.CreateObject("ADODB.RecordSet")
RSEVENT.Open "SELECT * FROM Events", Conn, 1, 3

Do while NOT RSEVENT.EOF
rsdate = RSEVENT("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(navmonth)) AND (Year(rsdate) = CInt(navyear)) Then%>

<br>
<%If RSBODY("Event_Display") = True Then%>
<%=RSEVENT("Category")%>
<%Else%>
<%=RSEVENT("Event_Name")%>
<% End If

End If
RSEVENT.movenext
Loop
RSEVENT.close
%>

</font></a></td>

<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
</tr>
<% Do while dateCounter <= lastDate %>
<tr>
<% Do while weekCount <= 7
dateSelect = dateCounter & "/" & navmonth & "/" & navyear %>

<% If dateCounter > lastDate Then %>
<td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>"><img src="im/clear.gif" height="1" width="1"></td>
<% else %>
<td height="<%=Cell_Height%>" bgcolor="<%=Date_Background_Color%>" valign="top"><a href="date.asp?date=<%=dateSelect%>"><font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><%=dateCounter%></font><font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">

<%
Set RSEVENT = Server.CreateObject("ADODB.RecordSet")
RSEVENT.Open "SELECT * FROM Events", Conn, 1, 3
Do while NOT RSEVENT.EOF
rsdate = RSEVENT("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(navmonth)) AND (Year(rsdate) = CInt(navyear)) Then%>

<br>
<%If RSBODY("Event_Display") = True Then%>
<%=RSEVENT("Category")%>
<%Else%>
<%=RSEVENT("Event_Name")%>
<% End If

End If
RSEVENT.movenext
Loop
RSEVENT.close
%>

</font></a></td>

<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
</tr>
<% Loop %>




</table>

</td>
</tr>
</table>

</td>
</tr>

<!-- Begin Ocean12 Technologies Copyright Notice -->
<!-- THIS CODE MUST NOT BE CHANGED -->
<tr>
<td align="center"><font face="Verdana" size="1">Maintained with the <a href="http://scripts.ocean12tech.com">Ocean12 ASP Calendar Manager</a> v1.01<br>&copy;2001 <a href="http://scripts.ocean12tech.com">Ocean12 Technologies</a>, all rights reserved.</font></td>
</tr>
<!-- End Ocean12 Technologies Copyright Notice -->

</table>

<%=RSBODY("Footer")%>

</body>
</html>
<!--#include file="dsn2.asp"-->
og date.asp kommer her (viser events):

<!--#include file="dsn.asp"-->
<!--#include file="body.asp"-->
<html>
<head>
<title><%=RSBODY("Page_Title")%></title>

<!--#include file="style.asp"-->

</head>
<body bgcolor="<%=RSBODY("Background_Color")%>" text="<%=RSBODY("Font_Color")%>" link="<%=RSBODY("Link_Color")%>" vlink="<%=RSBODY("Visited_Link_Color")%>" alink="<%=RSBODY("Active_Link_Color")%>">
<%

navmonth = request.querystring("month")
navyear = request.querystring("year")

If navmonth = "" Then
  navmonth = Month(Date)
End If

If navyear = "" Then
  navyear = Year(Date)
End If

firstday = Weekday(CDate(navmonth & "/" & 1 & "/" & navyear))


leapTestNumbers = navyear / 4
leapTest = (leapTestNumbers) - Round(leapTestNumbers)
If navmonth = 2 Then
  If leapTest <> 0 Then
    lastDate = 28
  Else
    lastDate = 29
  End If
ElseIf ((navmonth = 4) OR (navmonth = 6) OR (navmonth = 9) OR (navmonth = 11)) Then
  lastDate = 30
Else
  lastDate = 31
End If

lastMonth = navmonth - 1
lastYear = navyear
If lastMonth < 1 Then
  lastMonth = 12
  lastYear = lastYear - 1
End If

nextMonth = navmonth + 1
nextYear = navyear
If nextMonth >12 Then
  nextMonth = 1
  nextYear = nextYear + 1
End If


dateCounter = 1
weekCount = 1

DateEnd = lastDate
DateBegin = firstDate

Weekday_Font = RSBODY("Weekday_Font")
Weekday_Font_Size = RSBODY("Weekday_Font_Size")
Weekday_Font_Color = RSBODY("Weekday_Font_Color")
Weekday_Background_Color = RSBODY("Weekday_Background_Color")
Date_Font = RSBODY("Date_Font")
Date_Font_Size = RSBODY("Date_Font_Size")
Date_Font_Color = RSBODY("Date_Font_Color")
Date_Background_Color = RSBODY("Date_Background_Color")
Event_Font = RSBODY("Event_Font")
Event_Font_Size = RSBODY("Event_Font_Size")
Event_Font_Color = RSBODY("Event_Font_Color")
Cell_Width = RSBODY("Cell_Width")
Cell_Height = RSBODY("Cell_Height")
Cell_Background_Color = RSBODY("Cell_Background_Color")
Border_Size = RSBODY("Border_Size")
Border_Color = RSBODY("Border_Color")
%>
<%=RSBODY("Header")%>


<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center">

<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="<%=Border_Color%>">

<table border="0" cellpadding="2" cellspacing="<%=Border_Size%>">
<tr>
<td align="center" bgcolor="<%=Weekday_Background_Color%>"><font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><%If (RSBODY("Abbreviate_Months") = True) Then%><%=MonthName(Month(request("date")), true)%><%Else%><%=MonthName(Month(request("date")))%><%End If%>&nbsp;<%=Day(request("date"))%>,&nbsp;<%=Year(request("date"))%></font></td>
</tr>
<tr>
<td align="center" bgcolor="<%=Date_Background_Color%>">


<table border="0" cellpadding="0" cellspacing="2">
<%
eventEmpty = True

Set RSEVENT = Server.CreateObject("ADODB.RecordSet")
RSEVENT.Open "SELECT * FROM Events ORDER BY Date", Conn, 1, 3
Do while NOT RSEVENT.EOF
rsdate = RSEVENT("Date")
If (Day(rsdate) = Day(request("date"))) AND (Month(rsdate) = CInt(Month(request("date")))) AND (Year(rsdate) = CInt(Year(request("date")))) Then
eventEmpty = False
%>

<tr>
<td colspan="3"><font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>"><%=FormatDateTime(rsdate, vbLongTime)%>&nbsp;&nbsp;<%=RSEVENT("Event_Name")%></font></td>
</tr>

<%
If (NOT isNull(RSEVENT("Location"))) Then
%>
<tr>
<td><img src="../im/clear.gif" height="1" width="10"></td>
<td><font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=RSBODY("Link_Color")%>">Location</font></td>
<td><font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>"><%=RSEVENT("Location")%></font></td>
</tr>
<%End If%>

<tr>
<td><img src="../im/clear.gif" height="1" width="10"></td>
<td><font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=RSBODY("Link_Color")%>">Description</font></td>
<td><font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>"><%=RSEVENT("Description")%></font></td>
</tr>

<% End If
RSEVENT.movenext
Loop
RSEVENT.close
%>
</table>

<%
If (eventEmpty = True) Then%>
<font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">There are currently no events scheduled for this day.</font>
<%End If%>

</td>
</tr>
</table>

</td>
</tr>
</table>

</td>
</tr>

<!-- Begin Ocean12 Technologies Copyright Notice -->
<!-- THIS CODE MUST NOT BE CHANGED -->
<tr>
<td align="center"><font face="Verdana" size="1">Maintained with the <a href="http://scripts.ocean12tech.com">Ocean12 ASP Calendar Manager</a> v1.01<br>&copy;2001 <a href="http://scripts.ocean12tech.com">Ocean12 Technologies</a>, all rights reserved.</font></td>
</tr>
<!-- End Ocean12 Technologies Copyright Notice -->

</table>


<%=RSBODY("Footer")%>
</body>
</html>
<!--#include file="dsn2.asp"-->
Avatar billede rashid Praktikant
30. juni 2005 - 09:16 #1
jeg spekulerer om det er cdate-funktionen der skaber problemet ?
er der nogen af Jer ASP-hajer der kan gennemskue det ?
Avatar billede rashid Praktikant
30. juni 2005 - 09:40 #2
ok - jeg fandt ud af det selv... Det er cdate funktionen. rettelsen er blot at indsætte: Session.LCID = 1033 således at datoer fortolkes som amerikansk datoformat.

ps.: det kan ikke anbefales at kode kl. 01.30 - man oplever et underligt fænomen med at alle ord "flyver" rundt. :-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester