% @ Language="JavaScript" %>
Calendar
<%
var dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")
var Month30 = new Array(3, 5, 8, 10);
var Month31 = new Array(0, 2, 4, 6, 7, 9, 11);
var now = new Date();
/********** CHECK QUERY STRING **********/
var Month = (isNaN(Request("Month"))) ? now.getMonth() : parseInt(Request("Month")) - 1;
var Year = (isNaN(Request("Year"))) ? now.getYear() : parseInt(Request("Year"));
/********** END OF CHECK QUERY STRING **********/
/********** GET FIRST DAY OF MONTH **********/
var strDate = new Date(Year, Month, 1); // set date for the first of the selected month
var firstDay = strDate.getDay();
var daysInMonth = getdaysInMonth(Year, Month);
function getdaysInMonth(Year, Month){
if (Month == 1) {
if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0)) return 29;
else return 28;
}
for (month in Month30) {
if (Month == Month30[month]) return 30;
}
for (month in Month31) {
if (Month == Month31[month]) return 31;
}
}
/********** END OF GET FIRST DAY OF MONTH **********/
%>
<%
var monthL, monthR;
var yearL = yearR = Year;
/********** LEFT ARROW **********/
Response.write('');
if (Month <= 0) {
monthL = 12;
yearL = Year - 1;
}
else monthL = Month;
Response.write('');
Response.write('
');
Response.write('');
/********** END OF LEFT ARROW **********/
Response.write(' ');
Response.write(monthName[Month] + " " + Year);
Response.write(' ');
/********** RIGHT ARROW **********/
if (Month >= 11) {
monthR = 1;
yearR = Year + 1;
}
else monthR = Month + 2;
Response.write('');
Response.write('
');
Response.write('');
Response.write('');
/********** END OF RIGHT ARROW **********/
%>
<%
/********** TABLE HEADER **********/
for (i = 0; i < 7; i++){
Response.write('| ' + dayName[i] + ' | ');
}
Response.write("
");
/********** END OF TABLE HEADER **********/
/********** BODY OF THE TABLE **********/
var column = firstDay;
var Day = 1;
for (i = 0; i < firstDay; i++) {
Response.write('| | '); // beginning blank cells
}
for (i = 0; i < daysInMonth;) {
if (column++ != 7) {
if (now.getMonth() == Month && now.getDate() == Day && now.getYear() == Year)
Response.write('' + Day++ + " | ");
else Response.write('' + Day++ + " | ");
i++;
}
else {
Response.write("
");
column = 0;
}
}
if (column != 0 && column < 7) {
for (i = column; i < 7; i++) {
Response.write('| | '); // ending blank cells
}
}
/********** END OF BODY OF THE TABLE **********/
%>