Calendar.asp
'*********************************** '* Created by: Andrey Suvorov * '* e-mail: [email protected] * '* ********************************* %> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Calendar</title> <style fprolloverstyle>A:hover {color: #000000; text-decoration: blink} </style> </head> Dim myDate, viewmode mydate=request("md") if mydate="" then mydate=now viewmode=request("mode") if viewmode="" then viewmode=1 shownow=request("shownow") '----------------------------------------------------------------------------------------------------------------- Sub BuildYear(dddate) dddate=cdate("1/1/" & year(dddate)) response.write "<table border='0' cellspacing='4' cellpadding='0' width='525' style='border-top: 1 solid #000000;border-left: 1 solid #000000;border-right: 8 solid #000000;border-bottom: 8 solid #000000'>" response.write "<tr>" response.write "<td colspan='4' align='center' bgcolor='white'>" response.write "<a href='calendar.asp?md=" & dateadd("yyyy",-1,mydate) & "&mode=1'><font face='Arial Black' size='3' color='#000000'>" & "<<" & "</a> </b></font>" response.write "<font face='Tahoma' size='3' color='" & titlecol &"'><b>" & year(mydate) response.write " <a href='calendar.asp?md=" & dateadd("yyyy",1,mydate) & "&mode=1'><font face='Arial Black' size='3' color='#000000'>" & ">>" & "</a></b></font>" response.write "</b></font>" response.write "</td></tr>" for s=1 to 3 response.write "<tr>" for t=1 to 4 response.write "<td width='175'>" BuildCalendar dddate, false dddate=dateadd("m",1,dddate) response.write "</td>" next response.write "</tr>" next response.write "</table>" End sub '----------------------------------------------------------------------------------------------------------------- Sub BuildCalendar (myDate, showtoday) select case month(mydate) case 1 mnth="January" case 2 mnth="February" case 3 mnth="March" case 4 mnth="April" case 5 mnth="May" case 6 mnth="June" case 7 mnth="July" case 8 mnth="August" case 9 mnth="September" case 10 mnth="October" case 11 mnth="November" case 12 mnth="December" end select response.write "<table border='0' cellspacing='0' cellpadding='0' width='175' style='border: 1 solid #000000' bgcolor='#DFDFFF' height='9'>" response.write "<tr>" if showtoday=true then response.write "<td align='center' width='25' bgcolor='#000000' height='1'><b><a href='calendar.asp?md=" & dateadd("m",-1,mydate) & "&mode=0'><font color='#DFDFFF' size='2' face='Arial Black'><<</font></a></b></td>" response.write "<td align='center' width='125' bgcolor='#000000' colspan='5' height='1'>" response.write "<p align='center'><b><font face='Tahoma' size='3' color='#DFDFFF'>" & mnth & " </font><a href='calendar.asp?md=" & mydate & "&mode=1'><font face='Tahoma' size='3' color='#DFDFFF'>" & year(mydate) & "</font></b></td>" response.write "<td align='center' width='25' bgcolor='#000000' height='1'><b><a href='calendar.asp?md=" & dateadd("m",1,mydate) & "&mode=0'><font color='#DFDFFF' size='2' face='Arial Black'>>></font></a></b></td>" else response.write "<td align='center' width='25' bgcolor='#000000' height='1'> </td>" response.write "<td align='center' width='125' bgcolor='#000000' colspan='5' height='1'>" response.write "<p align='center'><b><a href='calendar.asp?md=" & mydate & "&mode=0'><font face='Tahoma' size='3' color='#DFDFFF'>" & mnth & "</font></a></b></td>" response.write "<td align='center' width='25' bgcolor='#000000' height='1'> </td>" end if response.write "</tr>" response.write "<tr>" response.write "<td align='center' width='25' bgcolor='#000000' style='border-top: 1 solid #EAEAFF' height='20'><font face='Tahoma' size='3' color='#FFFFFF'><b>S</b></font></td>" response.write "<td align='center' width='25' bgcolor='#000000' style='border-top: 1 solid #EAEAFF' height='20'><font face='Tahoma' size='3' color='#FFFFFF'><b>M</b></font></td>" response.write "<td align='center' width='25' bgcolor='#000000' style='border-top: 1 solid #EAEAFF' height='20'><font face='Tahoma' size='3' color='#FFFFFF'><b>T</b></font></td>" response.write "<td align='center' width='25' bgcolor='#000000' style='border-top: 1 solid #EAEAFF' height='20'><font face='Tahoma' size='3' color='#FFFFFF'><b>W</b></font></td>" response.write "<td align='center' width='25' bgcolor='#000000' style='border-top: 1 solid #EAEAFF' height='20'><font face='Tahoma' size='3' color='#FFFFFF'><b>T</b></font></td>" response.write "<td align='center' width='25' bgcolor='#000000' style='border-top: 1 solid #EAEAFF' height='20'><font face='Tahoma' size='3' color='#FFFFFF'><b>F</b></font></td>" response.write "<td align='center' width='25' bgcolor='#000000' style='border-top: 1 solid #EAEAFF' height='20'><font face='Tahoma' size='3' color='#FFFFFF'><b>S</b></font></td>" response.write "</tr>" d=1 '// first day of the month firstday=cdate(month(myDate) & "/1/" & year(myDate)) '// get the week day of the first day of the month startday= weekday(firstday) '//find out how many days in this month daysinmonth=datediff("d",firstday,dateadd("m",1,firstday)) '// we need this flag to verify if new month started flagNewMonth=false '// the calendar has 6 rows and 7 columns yto fill in. here is 6 rows for x= 1 to 6 '// start writing the row response.write "<tr height='20'>" '// start write columns for j=1 to 7 '// check if d become greater than day in this month, then '// start d from 1 (new month started). Set flag to TRUE '// do not make links for this new month days if d > daysinmonth then d=1 flagNewMonth=true end if '// now start to build the cells '// if month starting from let say Friday. We need to fill in days '// with from Monday to Thursday with days from the previous month if x=1 and startday > j then response.write "<td align='center' width='25'>" if showtoday=true then response.write "<font face='Tahoma' size='2' color='#808080'>" & day(dateadd("d",j - startday ,firstday)) & "</font>" else response.write "<font face='Tahoma' size='2' color='#808080'> </font>" end if '// start fill in cells with the dates for current month else '// build date for the link monthday=cdate(month(mydate) & "/" & d & "/" & year(mydate)) '// check if it is a current date, make a red border if formatdatetime(monthday, vbshortdate) = formatdatetime(now, vbshortdate) and flagNewMonth=false then response.write "<td align='center' style='border: 1 solid #FF0000' width='25'>" response.write "<a href='calendar.asp?md=" & mydate & "&mode=" & viewmode & "&shownow=" & monthday & "'><font face='Tahoma' size='2' color='black'><b>" & d & "</b></a></font>" '// start all other days else response.write "<td align='center' width='25'>" '// flag says that new month started, do not make any links if flagNewMonth=true then if showtoday=true then response.write "<font face='Tahoma' size='2' color='#808080'>" & d & "</font>" else response.write "<font face='Tahoma' size='2' color='#808080'> </font>" end if '// start current month links else '// check if current month day is not a weekend day or holidays '// if so do not make any links and make it red if j=1 or j=7 or _ monthday=cdate("7/4/" & year(monthday)) or _ monthday=cdate("1/1/" & year(monthday)) or _ monthday=cdate("12/25/" & year(monthday)) then response.write "<font face='Tahoma' size='2' color='red'>" & d & "</font>" '// all other days else response.write "<a href='calendar.asp?md=" & mydate & "&mode=" & viewmode & "&shownow=" & monthday & "'><font face='Tahoma' size='2' color='#000000'>" & d & "</a></font>" end if end if end if '// move to the next day d=d+1 end if '// finish the cell response.write "</font></td>" next '// finish the row response.write "</tr>" next if showtoday=true then response.write "<tr height='20'>" response.write "<td height='17' align='center' colspan='7' bgcolor='#000000' valign='middle'><b><a href='calendar.asp?md=" & now & "&mode=0'><font face='Tahoma' size='1' color='#DFDFFF'>TODAY " & formatdatetime(now,vbshortdate) & "</font></a></b></td>" response.write "</tr>" end if response.write "</table>" end sub '----------------------------------------------------------------------------------------------------------------- %> <body> if shownow <> "" then response.write "<font face='Tahoma' size='4'>Selected date: <b>" & shownow & "</b></font>" response.write "<br><br>" response.write "<a href='calendar.asp?md=" & mydate & "&mode=" & viewmode & "'><font face='Tahoma' size='2' color='red'><b>Click here to return to the calendar</b></font></a>" response.end end if if viewmode=0 then buildcalendar mydate, true else buildyear mydate end if %> </body>