Código fuente de 'Calendario.asp'

<html>
<head>
<title>Calendario - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>
<p align="center"><b><font size="3">Calendario</font></b></p>

<body style="font-family: Arial; font-size: 9pt">

<% 

' *****************************************************************
' *  Single Month Calendaring Code - Draws calendar of one month  *
' *                                                               *
' *  Works with sample data right out of the box - No coding      *
' *  needed to see how it works                                   *
' *                                                               *
' *  Have you wanted to draw a calendar?                          *
' *                                                               *
' *  The Month to draw is set by request.querystring("date")      *
' *  It will draw the entire month of each month, along with any  *
' *  leading or trailing days from the previous or next month.    *
' *  Change months with buttons on top:                           *
' *  * << - go back one year                                      *
' *  *  < - go back one month                                     *
' *  *  > - go forward one month                                  *
' *  * >> - go forward one year                                   *
' *                                                               *
' *  I tried to comment this code as best as i could, and I       *
' *  have probably over-commented it, but you can always erase    *
' *  them before using the code.                                  *
' *                                                               *
' *  Items to note:                                               *
' *  * Tested only with IE 5.0, there is much DHTML and           *
' *    cliend-side scripting that may not work in other browsers  *
' *  * Tested only with Regional Date Format as mm/dd/yyyy        *
' *  * Works as-is with weeks defined as Sunday thru Saturday     *
' *                                                               *
' *****************************************************************dim qsDate

dim qsDate

qsDate=request.querystring("date")
if isDate(qsDate) then
 'Start the Border Table
 response.write("<table cellspacing=0 border=0 cellpadding=0>" & chr(13))
 response.write(" <tr>" & chr(13))
 response.write("  <td width=1><img src=""dot.gif"" width=1 height=1></td>" & chr(13))
 response.write("  <td width=240><img src=""dot.gif"" width=240 height=1></td>" & chr(13))
 response.write("  <td width=1><img src=""dot.gif"" width=1 height=1></td>" & chr(13))
 response.write(" </tr>" & chr(13))
 response.write(" <tr>" & chr(13))
 response.write("  <td width=1><img src=""dot.gif"" width=1 height=""100%"" ></td>" & chr(13))
 response.write("  <td width=240>" & chr(13))

 DrawCalendarMonth (qsDate)

 'Close the Border Table
 response.write("  </td>" & chr(13))
 response.write("  <td width=1><img src=""dot.gif"" width=1 height=""100%"" ></td>" & chr(13))
 response.write(" </tr>" & chr(13))
 response.write(" <tr>" & chr(13))
 response.write("  <td width=1><img src=""dot.gif"" width=1 height=1></td>" & chr(13))
 response.write("  <td width=200><img src=""dot.gif"" width=240 height=1></td>" & chr(13))
 response.write("  <td width=1><img src=""dot.gif"" width=1 height=1></td>" & chr(13))
 response.write(" </tr>" & chr(13))
 response.write("</table>" & chr(13))
else
 response.write("<font face=verdana, arial>" & chr(13))
 if qsDate="" then
  response.write("No entraste una fecha, debes pasar un parámetro para que funcione la función, ejemplo: &quot;?date=&quot;, seguida por la fecha<br>Ejemplo: http://carpeta/Calendario.asp?date=2/7/01<br>" & chr(13))
 else
  response.write("La fecha introducida (" & qsDate & ") no es válida.<br>" & chr(13))
 end if
end if

Sub DrawNormalDay(DayNumber)
 ' Draws a day cell - date is in current month
 ' The response.write's are separate lines for clarity only
  response.write("    <td style=""cursor:hand;"" ")
  response.write("onmouseover=""this.style.backgroundColor='white';"" ")
  response.write("onmouseout=""this.style.backgroundColor='#cccccc';"" ")
  response.write("bgcolor=""#cccccc"" align=center>")
  response.write("<font face=verdana, arial size=2>" & DayNumber)
  response.write("</font></td>" & chr(13))
End Sub

Sub DrawOtherDay(DayNumber)
 ' Draws a day cell - date is in previous or next month
 ' The response.write's are separate lines for clarity only
 response.write("    <td bgcolor=""#eeeeee"" align=center>")
 response.write("<font face=verdana, arial size=2 color=""darkgray"">")
 response.write(DayNumber & "</font></td>" & chr(13))
End Sub

Sub DrawCalendarMonth(theDate)
dim thisMonthFirstDay
dim nextMonthFirstDay
dim thisMonthLastDay
dim lastMonthLastDay
dim calBeginDate
dim counter

 'Set the Date variables
 thisMonthFirstDay=cDate("1/" & month(theDate) & "/" & year(theDate))
 nextMonthFirstDay=dateAdd("m",1,thisMonthFirstDay)
 thisMonthLastDay=dateadd("d",-1,nextMonthFirstDay)
 lastMonthLastDay=dateadd("d",-1,thisMonthFirstDay)
 calBeginDate=dateadd("d",1-weekday(thisMonthFirstDay),thisMonthFirstDay)

 'Start the Calendar Table
 response.write("   <table width=240 bordercolor=white border=1 style=""border-collapse:collapse"">" & chr(13))
 response.write("    <tr bgcolor=beige>" & chr(13))
 response.write("     <td style=""cursor:hand;"" onmouseover=""this.style.backgroundColor='white';"" onmouseout=""this.style.backgroundColor='';"" onclick=""window.location='Calendario.asp?date=" & dateadd("yyyy",-1,theDate) & "';"" align=center><font face=verdana, arial size=2>&lt;&lt;</font></td>" & chr(13))
 response.write("     <td style=""cursor:hand;"" onmouseover=""this.style.backgroundColor='white';"" onmouseout=""this.style.backgroundColor='';"" onclick=""window.location='Calendario.asp?date=" & dateadd("m",-1,theDate) & "';"" align=center><font face=verdana, arial size=2>&lt;</font></td>" & chr(13))
 response.write("     <td colspan=3 align=center><font face=verdana, arial size=2>" & Monthname(month(theDate),true) & " '" & right(year(theDate),2) & "</font></td>" & chr(13))
 response.write("     <td style=""cursor:hand;"" onmouseover=""this.style.backgroundColor='white';"" onmouseout=""this.style.backgroundColor='';"" onclick=""window.location='Calendario.asp?date=" & dateadd("m",1,theDate) & "';"" align=center><font face=verdana, arial size=2>&gt;</font></td>" & chr(13))
 response.write("     <td style=""cursor:hand;"" onmouseover=""this.style.backgroundColor='white';"" onmouseout=""this.style.backgroundColor='';"" onclick=""window.location='Calendario.asp?date=" & dateadd("yyyy",1,theDate) & "';"" align=center><font face=verdana, arial size=2>&gt;&gt;</font></td>" & chr(13))
 response.write("    </tr>" & chr(13))
 response.write("    <tr bgcolor=""#aaaaaa"">" & chr(13))
 response.write("     <td align=center><font face=verdana, arial size=2>Su</font></td>" & chr(13))
 response.write("     <td align=center><font face=verdana, arial size=2>Mo</font></td>" & chr(13))
 response.write("     <td align=center><font face=verdana, arial size=2>Tu</font></td>" & chr(13))
 response.write("     <td align=center><font face=verdana, arial size=2>We</font></td>" & chr(13))
 response.write("     <td align=center><font face=verdana, arial size=2>Th</font></td>" & chr(13))
 response.write("     <td align=center><font face=verdana, arial size=2>Fr</font></td>" & chr(13))
 response.write("     <td align=center><font face=verdana, arial size=2>Sa</font></td>" & chr(13))
 response.write("    </tr>" & chr(13))

 'Start the First Row of Days
 response.write("    <tr>" & chr(13))

 ' If the First day of the month is not Sunday, draw previous month's ending days
 if weekday(thisMonthFirstDay)>1 then
  For counter = day(calBeginDate) to day(lastMonthLastDay)
   DrawOtherDay (counter)
  Next
 end if

 ' Draw each day of the specified month. After each Saturday, end the row & start a new one
 For Counter=1 to day(thisMonthLastDay)
  DrawNormalDay (counter)
  'if weekday(cDate(month(theDate) & "/" & counter & "/" & year(theDate))) = 7 then
  ' if weekday(cDate(month(theDate) & "/" & counter & "/" & year(theDate))) = 7 then
  if weekday(cDate(counter & "/" & month(theDate) & "/" &  year(theDate))) = 7 then
   response.write("    </tr>" & chr(13))
   response.write("    <tr>" & chr(13))
  end if
 next

 ' If the Last day of the month is not Saturday, draw next month's beginning days
 if weekday(thisMonthLastDay)<7 then
  For counter = 1 to 7-weekday(thisMonthLastDay)
   DrawOtherDay (counter)
  Next
 end if

 'End the Last Row and the Calendar
 response.write("    </tr>" & chr(13))
 response.write("   </table>" & chr(13))
end sub
%>

</body>
</html>