Step 1: Save the following files: CALENDAR. ASP
<% @ LANGUAGE = VBScript %>
<% Option Explicit %>
<%
Function sFont (iSize, sFace, sColor, bScale)
Dim sOutputStr
SOutputStr = "<FONT"
If sFace <> "then
SOutputStr = sOutputStr & "FACE =" & sFace &""
Else
SOutputStr = sOutputStr & "FACE = Helv"
End if
If iSize = "" then
ISize = 1
End if
If bScale then
ISize = cInt (iSize * 1)
End if
SOutputStr = sOutputStr & "SIZE =" & iSize
If sColor <> "" then
SOutputStr = sOutputStr & "COLOR =" & sColor
End if
SOutputStr = sOutputStr & ">"
SFont = sOutputStr
End Function
On Error Resume Next
Dim datecntrl, Dy, Mo, Yr, nextmonth, startwith, thisMo, thisYr, thisDate, the_type
Dim prevMonthLastDate, currMonthLastDate, I, j, lastnum, AnyDate, default_value
Datecntrl = Request ("object ")
Default_value = request ("value ")
The_type = request ("type ")
If the_type <> "datetime" then
The_type = "date"
End if
If default_value = "" then
Yr = year (date)
Mo = month (date)
Dy = day (date)
Else
Dim pos1
Dim deal_value
Deal_value = default_value
Pos1 = instr (deal_value ,"-")
Yr = cint (mid (deal_value, 1, pos1-1 ))
Deal_value = mid (deal_value, pos1 + 1)
Pos1 = instr (deal_value ,"-")
Mo = cint (mid (deal_value, 1, pos1-1 ))
If trim (the_type) = "date" then
Dy = cint (mid (deal_value, pos1 + 1 ))
Else
Dim H, M, S
Deal_value = mid (deal_value, pos1 + 1)
Pos1 = instr (deal_value ,"")
Dy = cint (mid (deal_value, 1, pos1-1 ))
Deal_value = mid (deal_value, pos1 + 1)
Pos1 = instr (deal_value ,":")
H = cint (mid (deal_value, 1, pos1-1 ))
Deal_value = mid (deal_value, pos1 + 1)
Pos1 = instr (deal_value ,":")
M = cint (mid (deal_value, 1, pos1-1 ))
S = cint (mid (deal_value, pos1 + 1 ))
End if
End if
Nextmonth = false
%>
<HTML>
<HEAD>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta name = "GENERATOR" content = "Microsoft FrontPage 4.0">
<Meta name = "ProgId" content = "FrontPage. Editor. Document">
<Style type = "text/css">
A
{FONT-SIZE: 13px; COLOR: #000000; TEXT-DECORATION: none}
A: hover
{COLOR: # ff0000;
}
</Style>
<TITLE> calendar </TITLE>
<Script language = "JavaScript">
// Check whether the string is a date. The returned values are false and true.
Function f_chkDate (datestr)
{
Var lthdatestr
If (datestr! = "")
Lthdatestr = datestr. length;
Else
Lthdatestr = 0;
Var tmpy = "";
Var tmpm = "";
Var tmpd = "";
// Var datestr;
Var status;
Status = 0;
If (lthdatestr = 0)
Return false;
If (lthdatestr> 10)
Return false;
For (I = 0; I <lthdatestr; I ++)
{If (datestr. charAt (I) = -)
{
Status ++;
}
If (status> 2)
{
// Alert ("Invalid format of date! ");
Return false;
}
If (status = 0) & (datestr. charAt (I )! = -))
{
Tmpy = tmpy + datestr. charAt (I)
}
If (status = 1) & (datestr. charAt (I )! = -))
{
Tmpm = tmpm + datestr. charAt (I)
}
If (status = 2) & (datestr. charAt (I )! = -))
{
Tmpd = tmpd + datestr. charAt (I)
}
}
Year = new String (tmpy );
Month = new String (tmpm );
Day = new String (tmpd );
// Tempdate = new String (year + month + day );
// Alert (tempdate );
If (tmpy. length! = 4) | (tmpm. length> 2) | (tmpd. length> 2 ))
{
// Alert ("Invalid format of date! ");
Return false;
}
If (! (1 <= month) & (12> = month) & (31> = day) & (1 <= day )))
{
// Alert ("Invalid month or day! ");
Return false;
}
If (! (Year % 4) = 0) & (month = 2) & (day = 29 ))
{
// Alert ("This is not a leap year! ");
Return false;
}
If (month <= 7) & (month % 2) = 0) & (day> = 31 ))
{
// Alert ("This month is a small month! ");
Return false;
}
If (month> = 8) & (month % 2) = 1) & (day> = 31 ))
{
// Alert ("This month is a small month! ");
Return false;
}
If (month = 2) & (day = 30 ))
{
// Alert ("The Febryary never has this day! ");
Return false;
}
Return true;
}
Function right (str, number)
{
Return str. substr (str. length-number, str. length );
}
Function setDate (Dy, Mo, Yr, vBool)
{
If (vBool)
{
If (Mo <10) Mo = "0" + Mo;
If (Dy <10) Dy = "0" + Dy;
<% If the_type = "datetime" then %>
Top. opener. <% = datecntrl %>. value = Yr + "-" + Mo + "-" + Dy + "" + userform. hour. value + ":" + userform. minute. value + ":" + userform. second. value;
<% Else %>
Top. opener. <% = datecntrl %>. value = Yr + "-" + Mo + "-" + Dy;
<% End if %>
Top. window. close ();
}
<% If the_type = "datetime" then %>
Self. location. href = "calendar. asp? Type = <% = the_type %> & object = <% = datecntrl %> & value = "+ Yr +"-"+ right (" 0 "+ Mo), 2) + "-" + right ("0" + Dy), 2) + "" + userform. hour. value + ":" + userform. minute. value + ":" + userform. second. value;
<% Else %>
Self. location. href = "calendar. asp? Type = <% = the_type %> & object = <% = datecntrl %> & value = "+ Yr +"-"+ right (" 0 "+ Mo), 2) + "-" + right ("0" + Dy), 2 );
<% End if %>
}
Function saveDate ()
{
<% If the_type = "datetime" then %>
Top. opener. <% = datecntrl %>. value = "<% = Yr &"-"& right (" 0 "+ cstr (Mo), 2) & "-" & right ("0" + cstr (Dy), 2) %> "+" "+ userform. hour. value + ":" + userform. minute. value + ":" + userform. second. value