Foros del Web » Programando para Internet » ASP Clásico »

Pregunta para expertos. Problema con weekday y bucle en calenadario

Estas en el tema de Pregunta para expertos. Problema con weekday y bucle en calenadario en el foro de ASP Clásico en Foros del Web. Estoy intentando usar un calendario de ASP101.com Pero quiero que la tabla empiece a partir del Lunes en lugar del Domingo. Pero como podreis ver ...
  #1 (permalink)  
Antiguo 02/05/2004, 08:44
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 22 años
Puntos: 0
Pregunta Pregunta para expertos. Problema con weekday y bucle en calenadario

Estoy intentando usar un calendario de ASP101.com
Pero quiero que la tabla empiece a partir del Lunes
en lugar del Domingo.
Pero como podreis ver se esta haciendo uso de WEEKDAY (Domingo es 1, Lunes es 2, etc)
y con ese resultado y la variable iDOW se pinta la tabla.
¿Como podria cambiarlo?
P.D:He simplificado el Codigo original para aislar el problema.
Pasando por el querystring date?=01/05/2004 por ejemplo se modifica,si no se pone nada busca la fecha del sistema.
Este es calender2.asp
<!--#Include File="functions2.asp"-->
<%Dim dDate ' Date we're displaying calendar for
Dim iDIM ' Days In Month
Dim iDOW ' Dia de la semana en que empieza el mes or the Day of Week were on.
Dim iCurrent ' Variable we use to hold current day of month as we write table
Dim ld_loopDate ' holds the loop position date as we loop thru the calender
Dim lb_eventsFound ' boolean true events were found for the loop date
DIM rstemp ' the recordset
'get the events for this month and keep them in the recordset
open_calender_connection()
Set rstemp = Server.CreateObject( "ADODB.Recordset" )
set rstemp=connCalender.execute( "select * from calender_event" )
' Call function to get the selected date
dDate = GetSelectedDate()
' write out the calender
With Response
' first (Outer) Table is simply to get the pretty border
.Write "<center><table BORDER='8' CELLSPACING='0' CELLPADDING='0'>"
.Write "<tr>"
.Write "<td>"
.Write "<table BORDER='1' CELLSPACING='0' CELLPADDING='1' bgcolor='#ffffff'>"
.Write "<tr>"
.Write "<td WIDTH='80' ALIGN='center' class='weekday'>Domingo<br></td>"
.Write "<td WIDTH='80' ALIGN='center' class='weekday'>Lunes<br></td>"
.Write "<td WIDTH='80' ALIGN='center' class='weekday'>Martes<br></td>"
.Write "<td WIDTH='80' ALIGN='center' class='weekday'>Miecoles<br></td>"
.Write "<td WIDTH='80' ALIGN='center' class='weekday'>Jueves<br></td>"
.Write "<td WIDTH='80' ALIGN='center' class='weekday'>Viernes<br></td>"
.Write "<td WIDTH='80' ALIGN='center' class='weekday'>Sabado<br></td>"
.Write "</tr>"
'Get day of the week the month starts on.
iDOW = GetWeekdayMonthStartsOn(dDate)
' Write spacer cells at beginning of first row if month doesn't start on a Sunday.
.Write vbTab & "<TR>" & vbCrLf
For iCurrent = 1 to iDOW - 1
.Write vbTab & vbTab & "<TD class='notaDay'>&nbsp;</TD>" & vbCrLf
Next
' Write days of month in proper day slots
For iCurrent = 1 to GetDaysInMonth(Month(dDate), Year(dDate))
' set the current date, were going to use it twice later on
ld_loopDate = cdate( iCurrent & "/" & Month(dDate) & "/" & Year(dDate) )
' If we're at the begginning of a row then write TR
if iDOW = 1 Then
.Write vbTab & "<TR>" & vbCrLf
End If
If iCurrent = Day(dDate) Then
.Write vbTab & vbTab & "<TD class='selectedDay' valign=top><FONT SIZE=""-1""><B>"
.Write iCurrent & "</B></FONT><BR>"
Else
.Write vbTab & vbTab & "<TD class='day' valign=top>"
.Write "<A HREF=""CALENDER2.ASP?date=" & replace( cstr( ld_loopDate ), "/", "-" ) & """>"
.Write "<FONT SIZE=""-1"">" & iCurrent & "</FONT></A><br>" & vbCrLf
End If
' write out events for the current day filtering the recordset and calling a function
rstemp.Filter = "start_dt <= " & ld_loopDate & " and end_dt >= " & ld_loopDate ' filter the recordset
lb_eventsFound = WriteEventLabelsForRecordset( rstemp )
rstemp.Filter = 0
If not lb_eventsFound then ' give the cell some height
.Write "<br><br>"
End If
lb_eventsFound = false ' reset the flag
' close up the current day
.Write "</TD>"
' If we're at the endof a row then close it up
If iDOW = 7 Then
.Write vbTab & "</TD>" & vbCrLf
iDOW = 0
End If

' Increment the days of the week
iDOW = iDOW + 1
Next
' Write spacer cells at end of last row if month doesn't end on a Saturday.
If iDOW <> 1 Then
Do While iDOW <= 7
.Write vbTab & vbTab & "<TD class='notaDay'>&nbsp;</TD>" & vbCrLf
iDOW = iDOW + 1
Loop
.Write vbTab & "</TR>" & vbCrLf
End If
' close up both the tables
.Write "</table>"
.Write "</td>"
.Write "</tr>"
.Write "</table></center>"
End With%>
<%
' Close the calender connection
close_calender_connection()
set rstemp = nothing
%>

Este es functions2.asp
<!--#Include File="../common/mini-adovbs.inc"-->
<%'FORMATO FECHA ESPAÑOL
session.LCID = 2058
' delcare instance variables
Dim connCalender
Public Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function


Public Function GetSelectedDate()
If IsDate(Request.QueryString("date")) Then
GetSelectedDate = CDate(Request.QueryString("date"))
Else
GetSelectedDate = Date()
End If
End Function


Public Function GetDaysInMonth(iMonth, iYear)
Dim dTemp
dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
GetDaysInMonth = Day(dTemp)
End Function ' GetDaysInMonth


Public Function WriteEventLabelsForRecordset( objRSTemp )
do until objRSTemp.eof
With Response
.Write "<a href='view_event.asp?event_id=" & objRSTemp("event_id") & "'>"
.Write objRSTemp("name") & "</a>"
.Write "<br>"
End With
WriteEventLabelsForRecordset=true
objRSTemp.movenext
loop
End Function ' WriteEventLabelsForRecordset

Public Function open_calender_connection()
' declare variables
Dim ls_path
Dim ls_username
Dim ls_password
Dim ls_connection
ls_username = ""
ls_password = ""
open_calender_connection = -1
ls_path = "C:\CALENDARIOMINI\calender.mdb"
ls_connection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & ls_path
Set connCalender = Server.CreateObject("ADODB.Connection")
connCalender.CommandTimeout = 30
connCalender.ConnectionTimeout = 20
connCalender.Open ls_connection, ls_username, ls_password
open_calender_connection = connCalender
If not connCalender.Errors.Count > 0 Then open_calender_connection = 1
End Function ' open_calender_connection

Public Function close_calender_connection()
connCalender.Close
Set connCalender = NOTHING
End Function ' close_calender_connection
%>
  #2 (permalink)  
Antiguo 02/05/2004, 15:09
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 22 años
Puntos: 0
P.d:

Algo que he visto por ahi es que se puede hacer que weekday sea 1 para lunes, 2 para marte,etc .
Seria cambiando la funcion de esta forma:

Public Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
'ESTO ES LO QUE CAMBIO
'GetWeekdayMonthStartsOn = WeekDay(dTemp)
'poniedolo asi lo cambio al formato español
GetWeekdayMonthStarts = WeekDay((dTemp),2)
End Function

Pero no se como modificar los bucles correctamente
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:32.