JavaScript DHTML/Development/Date — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 07:20, 26 мая 2010

A Dynamic Welcome Message

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 
John Wiley & Sons CopyRight 2001
*/
<HTML>
<HEAD>
<TITLE>Date String Maker</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function MakeArray(n) {
    this.length = n
    return this
}
monthNames = new MakeArray(12)
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"
dayNames = new MakeArray(7)
dayNames[1] = "Sunday"
dayNames[2] = "Monday"
dayNames[3] = "Tuesday"
dayNames[4] = "Wednesday"
dayNames[5] = "Thursday"
dayNames[6] = "Friday"
dayNames[7] = "Saturday"
function customDateString(oneDate) {
    var theDay = dayNames[oneDate.getDay() + 1]
    var theMonth = monthNames[oneDate.getMonth() + 1]
    var theYear = oneDate.getYear()
    theYear += (theYear < 100) ? 1900 : 0
    return theDay + ", " + theMonth + " " + oneDate.getDate() + ", " + theYear
}
function dayPart(oneDate) {
    var theHour = oneDate.getHours()
    if (theHour <6 )
        return "wee hours"
    if (theHour < 12)
        return "morning"
    if (theHour < 18)
        return "afternoon"
    return "evening"
}
</SCRIPT>
</HEAD>
<BODY>
<H1> Welcome!</H1>
<SCRIPT LANGUAGE="JavaScript">
today = new Date()
var header = (customDateString(today)).italics()
header += "<BR>We hope you are enjoying the "
header += dayPart(today) + "."
document.write(header)
</SCRIPT>
<HR>
</BODY>
</HTML>



Date: date, month, and year.

/* Note that the getMonth method returns 0 in January, 1 in February etc. 
So add 1 to the getMonth method to display the correct date.
*/
<html>
<body>
<script type="text/javascript">
    var d = new Date()
    document.write(d.getDate())
    document.write(".")
    document.write(d.getMonth() + 1)
    document.write(".")
    document.write(d.getFullYear())
</script>
</body>
</html>



Date: Week of the year

<html>
<head>
</head>
<body>
<SCRIPT Language="JavaScript">
    function weekNo() {
        
        var totalDays = 0;
        
        now = new Date();
        years=now.getYear();
    
        var days = new Array(12); 
        days[0] = 31;
        days[2] = 31;
        days[3] = 30;
        days[4] = 31;
        days[5] = 30;
        days[6] = 31;
        days[7] = 31;
        days[8] = 30;
        days[9] = 31;
        days[10] = 30;
        days[11] = 31;
 
        // is it a leap year
        //////////////////////////////////////////////////
        // has some year 2000 problem 
        // should check the year by dividing 4000
        //
        //////////////////////////////////////////////////
        if (Math.round(now.getYear()/4) == now.getYear()/4) {
            days[1] = 29
        }else{
            days[1] = 28
        }
 
        // If this is January 
        if (now.getMonth() == 0) { 
            totalDays = totalDays + now.getDate();
        }else{
            var curMonth = now.getMonth();
            for (var count = 1; count <= curMonth; count++) {
                totalDays = totalDays + days[count - 1];
        }
        totalDays = totalDays + now.getDate();
    }
    var agt=navigator.userAgent.toLowerCase();
    
    if ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) {
        var firstday=new Date("01/01/"+String(now.getYear())).getDay();
    }else {
        var firstday=new Date("01/01/"+String(1900+now.getYear())).getDay();
    }
    
    var diff=7-firstday+1;
    var week = Math.round((totalDays+diff-firstday)/7); return week;
}
document.write("Week "+weekNo()+" of "+years)
</SCRIPT>
</body>
</html>



Days Before Next Christmas Xmas

<!-- 
     Example File From "JavaScript and DHTML Cookbook"
     Published by O"Reilly & Associates
     Copyright 2003 Danny Goodman
-->
 
function getDaysBeforeNextXmas() {
    var oneMinute = 60 * 1000;
    var oneHour = oneMinute * 60;
    var oneDay = oneHour * 24;
    var today = new Date();
    var nextXmas = new Date();
    nextXmas.setMonth(11);
    nextXmas.setDate(25);
    if (today.getMonth() == 11 && today.getDate() > 25) {
        nextXmas.setFullYear(nextXmas.getFullYear() + 1);
    }
    var diff = nextXmas.getTime() - today.getTime();
    diff = Math.floor(diff/oneDay);
    return diff;
}
...
<p>Only 
<script type="text/javascript">document.write(getDaysBeforeNextXmas())</script>
shopping days until Christmas.</p>



Demo all methods in Date class

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
 * +-------------------------------------------------------------------------+
 * | jsPro - Date Test Page                                                  |
 * +-------------------------------------------------------------------------+
 * | Copyright (C) 2001-2003 Stuart Wigley                                   |
 * +-------------------------------------------------------------------------+
 * | This library is free software; you can redistribute it and/or modify it |
 * | under the terms of the GNU Lesser General Public License as published by|
 * | the Free Software Foundation; either version 2.1 of the License, or (at |
 * | your option) any later version.                                         |
 * |                                                                         |
 * | This library is distributed in the hope that it will be useful, but     |
 * | WITHOUT ANY WARRANTY; without even the implied warranty of              |
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
 * | General Public License for more details.                                |
 * |                                                                         |
 * | You should have received a copy of the GNU Lesser General Public License|
 * | along with this library; if not, write to the Free Software Foundation, |
 * | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA             |
 * +-------------------------------------------------------------------------+
 * | Authors:   Stuart Wigley <stuartwigley@yahoo.co.uk>                     |
 * +-------------------------------------------------------------------------+
 * $Id: date.html,v 1.5 2003/10/01 10:02:15 wigleys Exp $
-->
<html>
    <head>
        <title>jsPro - Date</title>
        <!-- error.js -->
        <script type="text/javascript">
/**
 * +-------------------------------------------------------------------------+
 * | jsPro - Error                                                           |
 * +-------------------------------------------------------------------------+
 * | Copyright (C) 2001-2003 Stuart Wigley                                   |
 * +-------------------------------------------------------------------------+
 * | This library is free software; you can redistribute it and/or modify it |
 * | under the terms of the GNU Lesser General Public License as published by|
 * | the Free Software Foundation; either version 2.1 of the License, or (at |
 * | your option) any later version.                                         |
 * |                                                                         |
 * | This library is distributed in the hope that it will be useful, but     |
 * | WITHOUT ANY WARRANTY; without even the implied warranty of              |
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
 * | General Public License for more details.                                |
 * |                                                                         |
 * | You should have received a copy of the GNU Lesser General Public License|
 * | along with this library; if not, write to the Free Software Foundation, |
 * | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA             |
 * +-------------------------------------------------------------------------+
 * | Authors:   Stuart Wigley <stuartwigley@yahoo.co.uk>                     |
 * |            Randolph Fielding <gator4life@cinci.rr.ru>                  |
 * +-------------------------------------------------------------------------+
 * $Id: error.js,v 1.15 2003/09/22 04:41:10 gator4life Exp $
 */

/**
 * Property used in <code>Error.handleError</code> to specify how errors are
 * reported. Permissable values are:
 *
 * 0    No errors are reported.
 * 1    Report the error name and error message using the status bar of the
 *      active browser window.
 * 2    Report the error name and error message using an alert box.
 * 3    Report the error name, error message and debug message using an alert
 *      box.
 * 4    Report the error name, error message and debug message using a debug
 *      window. An instance of the Debug() class must be available.
 */
Error.prototype.debugLevel = 4;

/**
 * Uses <code>Error.debugLevel</code> to control how errors are reported. If
 * <code>Error.debugLevel</code> is set to 4, you must substitute the name of
 * your <code>Debug()</code> instance for <code>oDebug</code> in the line
 * <code>var jsProDebugWindow = oDebug</code>.
 *
 * @summary             handles thrown exceptions
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 09/03/03
 * @interface           <code>Error.handleError()</code>
 * @requires            <code>Debug.print(vMixedValue, sMessageType)</code>
 * @see                 <code>Debug()</code>
 * @see                 <code>Debug.print()</code>
 */
Error.prototype.handleError = function() {
    var sDebugMessage = this.debug;
    var sErrorMessage = (sDebugMessage) ? sDebugMessage : "";
    switch (this.debugLevel) {
        case 0 :
            break;
        case 1 :
            window.status = this.name + ": " + this.message;
            break;
        case 2 :
            window.alert(this.name + "\n\n" + this.message);
            break;
        case 3 :
            window.alert(this.name + "\n\n" + this.message + "\n\n" + sErrorMessage);
            break;
        case 4 :
            var jsProDebugWindow = oDebug;
            if (jsProDebugWindow) {
                var oDebugWindow = jsProDebugWindow.debugWindow;
                if (oDebugWindow && !oDebugWindow.closed) {
                    jsProDebugWindow.print(this.name + " " + this.message + " " + sErrorMessage, 1);
                }
            }
    }
}

/**
 * Creates an object that is a subclass of Error for handling
 * ArrayIndexOutOfBounds exceptions.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 06/27/03
 * @interface           <code>new ArrayIndexOutOfBoundsException(sMethodName,
 *                      iIndex, iArrayLength)</code>
 * @param sMethodName   the name of the method where the exception was thrown
 * @param iIndex        the index of a hypothetical array member attempting to
 *                      be accessed
 * @param iArrayLength  the length of the array
 */
function ArrayIndexOutOfBoundsException(sMethodName, iIndex, iArrayLength) {
    this.name = "ArrayIndexOutOfBoundsException";
    this.message = sMethodName + " has been accessed with an illegal index that is either negative or greater than the size of the array.";
    this.debug = "Attempting to access index " + iIndex.toString() + ", but array has an index range of 0 to " + (iArrayLength - 1).toString() + ".";
}
ArrayIndexOutOfBoundsException.prototype = new Error();

/**
 * Creates an object that is a subclass of Error for handling IllegalArgument
 * exceptions.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 07/24/03
 * @interface           <code>new IllegalArgumentException(sMethodName,
 *                      vExpectedArgs, iActualArgs)</code>
 * @param sMethodName   the name of the method where the exception was thrown
 * @param vExpectedArgs the number of arguments expected
 * @param iActualArgs   the number of arguments received
 */
function IllegalArgumentException(sMethodName, vExpectedArgs, iActualArgs) {
    this.name = "IllegalArgumentException";
    this.message = sMethodName + " has been passed an illegal number of arguments.";
    this.debug = "Expected " + vExpectedArgs.toString() + " argument(s), but received " + iActualArgs.toString() + " argument(s).";
}
IllegalArgumentException.prototype = new Error();

/**
 * Creates an object that is a subclass of Error for handling IllegalValue
 * exceptions.
 *
 * @author              Randolph Fielding
 * @version             1.0, 09/22/03
 * @interface           <code>new IllegalValueException(sMethodName,
 *                      sVariableName, vExpectedVal, vActualVal)</code>
 * @param sMethodName   the name of the method where the exception was thrown
 * @param sVariableName the name of the variable containing the illegal value
 * @param vExpectedVal  the value expected in the variable containing the
 *                      illegal value
 * @param vActualVal    the value currently in the variable containing the
 *                      illegal value
 */
function IllegalValueException(sMethodName, sVariableName, vExpectedVal, vActualVal) {
    this.name = "IllegalValueException";
    this.message = sMethodName + " has encountered an illegal value in variable " + sVariableName + "."
    this.debug = "Expected a value of " + vExpectedVal.toString() + ", but contains a value of " + vActualVal.toString() + "."
}
IllegalValueException.prototype = new Error();

/**
 * Creates an object that is a subclass of Error for handling
 * MethodNotAvailable exceptions.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 06/27/03
 * @interface           <code>new MethodNotAvailableException(sMethodName,
 *                      sMethodNameNA)</code>
 * @param sMethodName   the name of the method where the exception was thrown
 * @param sMethodNameNA the name of the method that was not available
 */
function MethodNotAvailableException(sMethodName, sMethodNameNA) {
    this.name = "MethodNotAvailableException";
    this.message = "A method has been called that is not available.";
    this.debug = sMethodName + " attempted to call " + sMethodNameNA + ".";
}
MethodNotAvailableException.prototype = new Error();

/**
 * Creates an object that is a subclass of Error for handling
 * PropertyNotAvailable exceptions.
 *
 * @author              Randolph Fielding
 * @version             1.1, 08/01/03
 * @interface           <code>new PropertyNotAvailableException(sMethodName,
 *                      sPropNameNA)</code>
 * @param sMethodName   the name of the method where the exception was thrown
 * @param sPropNameNA   the name of the property that was not available
 */
function PropertyNotAvailableException(sMethodName, sPropNameNA) {
    this.name = "PropertyNotAvailableException";
    this.message = "A property has been accessed that is not available.";
    this.debug = sMethodName + " attempted to access " + sPropNameNA + ".";
}
PropertyNotAvailableException.prototype = new Error();

/**
 * Creates an object that is a subclass of Error for handling TypeMismatch
 * exceptions.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 07/24/03
 * @interface           <code>new TypeMismatchException(sMethodName,
 *                      sExpectedType, sActualType)</code>
 * @param sMethodName   the name of the method where the exception was thrown
 * @param sExpectedType the name of the expected type of an argument
 * @param sActualType   the name of the actual type of an argument
 */
function TypeMismatchException(sMethodName, sExpectedType, sActualType) {
    this.name = "TypeMismatchException";
    this.message = sMethodName + " has been passed an argument with an illegal or inappropriate type.";
    this.debug = "Expected an argument with a type of " + sExpectedType + ", but received an argument with a type of " + sActualType + ".";
}
TypeMismatchException.prototype = new Error();

/**
 * Creates an object that is a subclass of Error for handling Unknown
 * exceptions.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 06/27/03
 * @interface           <code>new UnknownException(sMethodName)</code>
 * @param sMethodName   the name of the method where the exception was thrown
 */
function UnknownException(sMethodName) {
    this.name = "UnknownException";
    this.message = "An unknown error has occurred in " + sMethodName + ".";
}
UnknownException.prototype = new Error();
        </script>
        <!-- debug.js -->
        <script type="text/javascript">
/**
 * +-------------------------------------------------------------------------+
 * | jsPro - Debug                                                           |
 * +-------------------------------------------------------------------------+
 * | Copyright (C) 2001-2003 Stuart Wigley                                   |
 * +-------------------------------------------------------------------------+
 * | This library is free software; you can redistribute it and/or modify it |
 * | under the terms of the GNU Lesser General Public License as published by|
 * | the Free Software Foundation; either version 2.1 of the License, or (at |
 * | your option) any later version.                                         |
 * |                                                                         |
 * | This library is distributed in the hope that it will be useful, but     |
 * | WITHOUT ANY WARRANTY; without even the implied warranty of              |
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
 * | General Public License for more details.                                |
 * |                                                                         |
 * | You should have received a copy of the GNU Lesser General Public License|
 * | along with this library; if not, write to the Free Software Foundation, |
 * | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA             |
 * +-------------------------------------------------------------------------+
 * | Authors:   Stuart Wigley <stuartwigley@yahoo.co.uk>                     |
 * |            Randolph Fielding <gator4life@cinci.rr.ru>                  |
 * +-------------------------------------------------------------------------+
 * $Id: debug.js,v 1.6 2003/09/22 05:07:41 gator4life Exp $
 */

/**
 * Creates an object that opens a window for debugging.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 09/05/03
 * @interface           <code>new Debug()</code>
 */
function Debug() {
    this.debugWindow = window.open("../debug/debug.html", "debug", "width=400,height=600,resizable=yes,scrollbars=yes");
}

/**
 * Clears the contents of the debug window.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 09/05/03
 * @interface           <code>Debug.clear()</code>
 * @return              <code>true</code> if no exceptions are encountered
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              UnknownException
 */
Debug.prototype.clear = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments != 0) {
            throw vError = new IllegalArgumentException("Debug.clear", 0, iNumArguments);
        }
        var oMessageContainer = document.getElementById("messageContainer");
        if (!oMessageContainer) {
            throw vError = new UnknownException("Debug.clear");
        }
        while (oMessageContainer.hasChildNodes()) {
            oMessageContainer.removeChild(oMessageContainer.firstChild);
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : true;
    }
}

/**
 * Displays content within the debug window.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 09/05/03
 * @interface           <code>Debug.print(vMixedValue)</code>
 * @interface           <code>Debug.print(vMixedValue, iMessageType)</code>
 * @param vMixedValue   content to be displayed within the debug window
 * @param iMessageType  an integer representing the type of content to display
 *                      within the debug window (information: 0; error: 1)
 *                      (optional)
 * @return              <code>true</code> if no exceptions are encountered
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              IllegalValueException
 * @throws              TypeMismatchException
 * @throws              UnknownException
 */
Debug.prototype.print = function(vMixedValue) {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        var iMessageType = 0;
        if ((iNumArguments < 1) || (iNumArguments > 2)) {
            throw vError = new IllegalArgumentException("Debug.print", "1 or 2", iNumArguments);
        } else if (iNumArguments == 2) {
            iMessageType = arguments[1];
        }
        if ((typeof iMessageType != "number") || (iMessageType.toString().indexOf(".") != -1)) {
            throw vError = new TypeMismatchException("Debug.print", "integer", typeof iMessageType);
        }
        if ((iMessageType != 0) && (iMessageType != 1)) {
            throw vError = new IllegalValueException("Debug.print", "iMessageType", "0 or 1", iMessageType);
        }
        var oDebugWindow = this.debugWindow;
        if (!oDebugWindow || oDebugWindow.closed) {
            throw vError = new UnknownException("Debug.print");
        }
        var oDocument = oDebugWindow.document;
        if (!oDocument) {
            throw vError = new UnknownException("Debug.print");
        }
        var oMessageContainer = oDocument.getElementById("messageContainer");
        if (!oMessageContainer) {
            throw vError = new UnknownException("Debug.print");
        }
        var oTitleRow = oDocument.createElement("tr");
        var oTitleCell = oDocument.createElement("td");
        var oBodyRow = oDocument.createElement("tr");
        var oBodyCell = oDocument.createElement("td");
        if (!oTitleRow || !oTitleCell || !oBodyRow || !oBodyCell) {
            throw vError = new UnknownException("Debug.print");
        }
        var oTitleRowStyle = oTitleRow.style;
        if (oTitleRowStyle) {
            oTitleRowStyle.backgroundColor = "#EEE";
            oTitleRowStyle.fontWeight = 700;
        }
        var sOutputString = vMixedValue.toString();
        var sTitle = "info";
        var sBody = sOutputString;
        if (iMessageType == 1) {
            sTitle = sOutputString.match(/\w+/);
            sBody = sOutputString.replace(/\w+/, "");
            var oBodyCellStyle = oBodyCell.style;
            if (oBodyCellStyle) {
                oBodyCell.style.backgroundColor = "#FCC";
            }
        }
        oMessageContainer.appendChild(oTitleRow);
        oTitleRow.appendChild(oTitleCell);
        oTitleCell.appendChild(oDocument.createTextNode(sTitle));
        oMessageContainer.appendChild(oBodyRow);
        oBodyRow.appendChild(oBodyCell);
        oBodyCell.appendChild(oDocument.createTextNode(sBody));
        oDebugWindow.focus();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : true;
    }
}
        </script>
        <!-- test.js -->
        <script type="text/javascript">
/**
 * +-------------------------------------------------------------------------+
 * | jsPro - Test                                                            |
 * +-------------------------------------------------------------------------+
 * | Copyright (C) 2001-2003 Stuart Wigley                                   |
 * +-------------------------------------------------------------------------+
 * | This library is free software; you can redistribute it and/or modify it |
 * | under the terms of the GNU Lesser General Public License as published by|
 * | the Free Software Foundation; either version 2.1 of the License, or (at |
 * | your option) any later version.                                         |
 * |                                                                         |
 * | This library is distributed in the hope that it will be useful, but     |
 * | WITHOUT ANY WARRANTY; without even the implied warranty of              |
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
 * | General Public License for more details.                                |
 * |                                                                         |
 * | You should have received a copy of the GNU Lesser General Public License|
 * | along with this library; if not, write to the Free Software Foundation, |
 * | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA             |
 * +-------------------------------------------------------------------------+
 * | Authors:   Stuart Wigley <stuartwigley@yahoo.co.uk>                     |
 * |            Randolph Fielding <gator4life@cinci.rr.ru>                  |
 * +-------------------------------------------------------------------------+
 * $Id: test.js,v 1.6 2003/09/15 05:07:09 gator4life Exp $
 */

/**
 * Creates an object that provides methods for testing all jsPro libraries.
 *
 * @author              Stuart Wigley
 * @version             1.0, 07/24/03
 * @interface           <code>new Test()</code>
 */
function Test() { }

/**
 * Evaluates and returns the result of a jsPro method using assumptions about
 * the structure and ids of HTML elements in the jsPro HTML test files.
 *
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/20/03
 * @interface           <code>Test.evaluateMethod(oButton, sClass)</code>
 * @param oButton       the HTML input-button element that is clicked
 * @param sClass        the name of the jsPro class instance being tested
 * @return              the result of attempting to evaluate a jsPro method
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              TypeMismatchException
 */
Test.prototype.evaluateMethod = function(oButton, sClass) {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments != 2) {
            throw vError = new IllegalArgumentException("Error.evaluateMethod", 2, iNumArguments);
        }
        if (typeof oButton != "object") {
            throw vError = new TypeMismatchException("Error.evaluateMethod", "object", typeof oButton);
        }
        if (typeof sClass != "string") {
            throw vError = new TypeMismatchException("Error.evaluateMethod", "string", typeof sClass);
        }
        var sMethodName = oButton.id;
        var oInput1 = document.getElementById(sMethodName + "1");
        var oInput2 = document.getElementById(sMethodName + "2");
        var oInput3 = document.getElementById(sMethodName + "3");
        var oOutput = document.getElementById(sMethodName + "Result");
        var sArguments = "";
        if (oInput1) {
            var sInput1Value = oInput1.value;
            if (sInput1Value != "") {
                var fInput1Value = parseFloat(sInput1Value);
                sArguments += (isNaN(fInput1Value)) ? "\"" + sInput1Value + "\"" : fInput1Value;
            }
        }
        if (oInput2) {
            var sInput2Value = oInput2.value;
            if (sInput2Value != "") {
                var fInput2Value = parseFloat(sInput2Value);
                sArguments += (isNaN(fInput2Value)) ? ", \"" + sInput2Value + "\"" : ", " + fInput2Value;
            }
        }
        if (oInput3) {
            var sInput3Value = oInput3.value;
            if (sInput3Value != "") {
                var fInput3Value = parseFloat(sInput3Value);
                sArguments += (isNaN(fInput3Value)) ? ", \"" + sInput3Value + "\"" : ", " + fInput3Value;
            }
        }
        var vResult = eval(sClass + "." + sMethodName + "(" + sArguments + ")");
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        if (oOutput) {
            oOutput.value = vResult;
        }
    }
}
        </script>
        <!-- date.js -->
        <script type="text/javascript">
/**
 * +-------------------------------------------------------------------------+
 * | jsPro - Date                                                            |
 * +-------------------------------------------------------------------------+
 * | Copyright (C) 2001-2003 Stuart Wigley                                   |
 * +-------------------------------------------------------------------------+
 * | This library is free software; you can redistribute it and/or modify it |
 * | under the terms of the GNU Lesser General Public License as published by|
 * | the Free Software Foundation; either version 2.1 of the License, or (at |
 * | your option) any later version.                                         |
 * |                                                                         |
 * | This library is distributed in the hope that it will be useful, but     |
 * | WITHOUT ANY WARRANTY; without even the implied warranty of              |
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
 * | General Public License for more details.                                |
 * |                                                                         |
 * | You should have received a copy of the GNU Lesser General Public License|
 * | along with this library; if not, write to the Free Software Foundation, |
 * | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA             |
 * +-------------------------------------------------------------------------+
 * | Authors:   Stuart Wigley <stuartwigley@yahoo.co.uk>                     |
 * |            Randolph Fielding <gator4life@cinci.rr.ru>                  |
 * +-------------------------------------------------------------------------+
 * $Id: date.js,v 1.8 2003/10/01 10:02:14 wigleys Exp $
 */

/**
 * Implements the functionality within the date() function of PHP and returns
 * this date formatted according to the specified format string. See
 * http://www.php.net/manual/en/function.date.php for more information.
 *
 * The following list of string characters are recognized in the specified
 * format string:
 *
 * a - Lowercase Ante Meridiem/Post Meridiem ("am" or "pm")
 * A - Uppercase Ante Meridiem/Post Meridiem ("AM" or "PM")
 * B - Swatch Internet Time ("@000" to "@999")
 * d - Day of month with leading zeroes ("01" to "31")
 * D - Three-letter, shortened name of day of week ("Mon" to "Sun")
 * F - Full name of month of year ("January" to "December")
 * g - 12-hour format of hour of day without leading zeros ("1" to "12")
 * G - 24-hour format of hour of day without leading zeros ("0" to "23")
 * h - 12-hour format of hour of day with leading zeros ("01" to "12")
 * H - 24-hour format of hour of day with leading zeros ("00" to "23")
 * i - Minutes of hour with leading zeros ("00" to "59")
 * I - << NOT IMPLEMENTED >>
 * j - Day of month without leading zeros ("1" to "31")
 * l - Full name of day of week ("Monday" to "Sunday")
 * L - Leap year or not? ("1" for true or "0" for false)
 * m - Month of year with leading zeros ("01" to "12")
 * M - Three-letter, shortened name of month of year ("Jan" to "Dec")
 * n - Month of year without leading zeros ("1" to "12")
 * O - Greenwich Mean Time (GMT) offset ("[+/-]HHMM")
 * r - RFC 822 format (e.g. "Thu, 21 Dec 2000 16:01:07 +0200")
 * s - Seconds of minute with leading zeros ("00" to "59")
 * S - Ordinal suffix (in English) of day of month ("st", "nd", "rd" or "th")
 * t - Days in month ("28" to "31")
 * T - << NOT IMPLEMENTED >>
 * U - Seconds since the UNIX epoch (1 Jan 1970 00:00:00 GMT)
 * w - Day of week ("0" for Sunday to "6" for Saturday)
 * W - ISO 8601 week number of year ("01" to "53")
 * y - Two-digit year (e.g. "99" or "03")
 * Y - Four-digit year (e.g. "1999" or "2003")
 * z - Day of year ("1" to "366")
 * Z - Greenwich Mean Time (GMT) offset in seconds ("-43200" to "43200")
 *
 * @summary             format date
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/18/03
 * @interface           <code>Date.formatDate(sFormatString)</code>
 * @requires            <code>Date.getDayOfYear()</code>
 * @requires            <code>Date.getDaysInMonth()</code>
 * @requires            <code>Date.getGMTOffset()</code>
 * @requires            <code>Date.getLong12Hours()</code>
 * @requires            <code>Date.getLong24Hours()</code>
 * @requires            <code>Date.getLongDate()</code>
 * @requires            <code>Date.getLongDayName()</code>
 * @requires            <code>Date.getLongMinutes()</code>
 * @requires            <code>Date.getLongMonth()</code>
 * @requires            <code>Date.getLongMonthName()</code>
 * @requires            <code>Date.getLongSeconds()</code>
 * @requires            <code>Date.getMeridiem()</code>
 * @requires            <code>Date.getOrdinalSuffix()</code>
 * @requires            <code>Date.getRFC822Date()</code>
 * @requires            <code>Date.getShort12Hours()</code>
 * @requires            <code>Date.getShort24Hours()</code>
 * @requires            <code>Date.getShortDayName()</code>
 * @requires            <code>Date.getShortMonth()</code>
 * @requires            <code>Date.getShortMonthName()</code>
 * @requires            <code>Date.getShortYear()</code>
 * @requires            <code>Date.getSwatchTime()</code>
 * @requires            <code>Date.getTimeSeconds()</code>
 * @requires            <code>Date.getTimezone()</code>
 * @requires            <code>Date.getTimezoneOffsetSeconds()</code>
 * @requires            <code>Date.getWeekOfYear()</code>
 * @requires            <code>Date.isDaylightSavingsTime()</code>
 * @requires            <code>Date.isLeapYear()</code>
 * @param sFormatString the string to format against
 * @return              the formatted date string
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              TypeMismatchException
 * @throws              UnknownException
 * @see                 <code>Date.getDayOfYear()</code>
 * @see                 <code>Date.getDaysInMonth()</code>
 * @see                 <code>Date.getGMTOffset()</code>
 * @see                 <code>Date.getLong12Hours()</code>
 * @see                 <code>Date.getLong24Hours()</code>
 * @see                 <code>Date.getLongDate()</code>
 * @see                 <code>Date.getLongDayName()</code>
 * @see                 <code>Date.getLongMinutes()</code>
 * @see                 <code>Date.getLongMonth()</code>
 * @see                 <code>Date.getLongMonthName()</code>
 * @see                 <code>Date.getLongSeconds()</code>
 * @see                 <code>Date.getMeridiem()</code>
 * @see                 <code>Date.getOrdinalSuffix()</code>
 * @see                 <code>Date.getRFC822Date()</code>
 * @see                 <code>Date.getShort12Hours()</code>
 * @see                 <code>Date.getShort24Hours()</code>
 * @see                 <code>Date.getShortDayName()</code>
 * @see                 <code>Date.getShortMonth()</code>
 * @see                 <code>Date.getShortMonthName()</code>
 * @see                 <code>Date.getShortYear()</code>
 * @see                 <code>Date.getSwatchTime()</code>
 * @see                 <code>Date.getTimeSeconds()</code>
 * @see                 <code>Date.getTimezone()</code>
 * @see                 <code>Date.getTimezoneOffsetSeconds()</code>
 * @see                 <code>Date.getWeekOfYear()</code>
 * @see                 <code>Date.isDaylightSavingsTime()</code>
 * @see                 <code>Date.isLeapYear()</code>
 */
Date.prototype.formatDate = function(sFormatString) {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("getDayOfYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getDayOfYear");
        }
        if (!("getDaysInMonth" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getDaysInMonth");
        }
        if (!("getGMTOffset" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getGMTOffset");
        }
        if (!("getLong12Hours" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLong12Hours");
        }
        if (!("getLong24Hours" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLong24Hours");
        }
        if (!("getLongDate" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLongDate");
        }
        if (!("getLongDayName" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLongDayName");
        }
        if (!("getLongMinutes" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLongMinutes");
        }
        if (!("getLongMonth" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLongMonth");
        }
        if (!("getLongMonthName" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLongMonthName");
        }
        if (!("getLongSeconds" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getLongSeconds");
        }
        if (!("getMeridiem" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getMeridiem");
        }
        if (!("getOrdinalSuffix" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getOrdinalSuffix");
        }
        if (!("getRFC822Date" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getRFC822Date");
        }
        if (!("getShort12Hours" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getShort12Hours");
        }
        if (!("getShort24Hours" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getShort24Hours");
        }
        if (!("getShortDayName" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getShortDayName");
        }
        if (!("getShortMonth" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getShortMonth");
        }
        if (!("getShortMonthName" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getShortMonthName");
        }
        if (!("getShortYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getShortYear");
        }
        if (!("getSwatchTime" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getSwatchTime");
        }
        if (!("getTimeSeconds" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getTimeSeconds");
        }
        if (!("getTimezone" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getTimezone");
        }
        if (!("getTimezoneOffsetSeconds" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getTimezoneOffsetSeconds");
        }
        if (!("getWeekOfYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.getWeekOfYear");
        }
        if (!("isDaylightSavingsTime" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.isDaylightSavingsTime");
        }
        if (!("isLeapYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.formatDate", "Date.isLeapYear");
        }
        if (iNumArguments != 1) {
            throw vError = new IllegalArgumentException("Date.formatDate", 1, iNumArguments);
        }
        if (typeof sFormatString != "string") {
            throw vError = new TypeMismatchException("Date.formatDate", "string", typeof sFormatString);
        }
        var sDayOfYear = this.getDayOfYear();
        var sDaysInMonth = this.getDaysInMonth();
        var sGMTOffset = this.getGMTOffset();
        var sIsDaylightSavingsTime = this.isDaylightSavingsTime();
        var sIsLeapYear = this.isLeapYear();
        var sLong12Hours = this.getLong12Hours();
        var sLong24Hours = this.getLong24Hours();
        var sLongDate = this.getLongDate();
        var sLongDayName = this.getLongDayName();
        var sLongMinutes = this.getLongMinutes();
        var sLongMonth = this.getLongMonth();
        var sLongMonthName = this.getLongMonthName();
        var sLongSeconds = this.getLongSeconds();
        var sMeridiem = this.getMeridiem();
        var sOrdinalSuffix = this.getOrdinalSuffix();
        var sRFC822Date = this.getRFC822Date();
        var sShort12Hours = this.getShort12Hours();
        var sShort24Hours = this.getShort24Hours();
        var sShortDayName = this.getShortDayName();
        var sShortMonth = this.getShortMonth();
        var sShortMonthName = this.getShortMonthName();
        var sShortYear = this.getShortYear();
        var sSwatchTime = this.getSwatchTime();
        var sTimeSeconds = this.getTimeSeconds();
        var sTimezone = this.getTimezone();
        var sTimezoneOffsetSeconds = this.getTimezoneOffsetSeconds();
        var sWeekOfYear = this.getWeekOfYear();
        if (!sDayOfYear      || !sDaysInMonth           || !sGMTOffset     || !sIsDaylightSavingsTime ||
            !sIsLeapYear     || !sLong12Hours           || !sLong24Hours   || !sLongDate              ||
            !sLongDayName    || !sLongMinutes           || !sLongMonth     || !sLongMonthName         ||
            !sLongSeconds    || !sMeridiem              || !sOrdinalSuffix || !sRFC822Date            ||
            !sShort12Hours   || !sShort24Hours          || !sShortDayName  || !sShortMonth            ||
            !sShortMonthName || !sShortYear             || !sSwatchTime    || !sTimeSeconds           ||
            !sTimezone       || !sTimezoneOffsetSeconds || !sWeekOfYear) {
            throw vError = new UnknownException("Date.formatDate");
        }
        var sFormatStringLength = sFormatString.length;
        var sFormattedDate = "";
        for (var i = 0; i < sFormatStringLength; i++) {
            var sChar = sFormatString.charAt(i);
            switch (sChar) {
                case "a" : sFormattedDate += sMeridiem; break;
                case "A" : sFormattedDate += sMeridiem.toUpperCase(); break;
                case "B" : sFormattedDate += sSwatchTime; break;
                case "d" : sFormattedDate += sLongDate; break;
                case "D" : sFormattedDate += sShortDayName; break;
                case "F" : sFormattedDate += sLongMonthName; break;
                case "g" : sFormattedDate += sShort12Hours; break;
                case "G" : sFormattedDate += sShort24Hours; break;
                case "h" : sFormattedDate += sLong12Hours; break;
                case "H" : sFormattedDate += sLong24Hours; break;
                case "i" : sFormattedDate += sLongMinutes; break;
                case "I" : sFormattedDate += sIsDaylightSavingsTime; break;
                case "j" : sFormattedDate += this.getDate().toString(); break;
                case "l" : sFormattedDate += sLongDayName; break;
                case "L" : sFormattedDate += sIsLeapYear; break;
                case "m" : sFormattedDate += sLongMonth; break;
                case "M" : sFormattedDate += sShortMonthName; break;
                case "n" : sFormattedDate += sShortMonth; break;
                case "O" : sFormattedDate += sGMTOffset; break;
                case "r" : sFormattedDate += sRFC822Date; break;
                case "s" : sFormattedDate += sLongSeconds; break;
                case "S" : sFormattedDate += sOrdinalSuffix; break;
                case "t" : sFormattedDate += sDaysInMonth; break;
                case "T" : sFormattedDate += sTimezone; break;
                case "U" : sFormattedDate += sTimeSeconds; break;
                case "w" : sFormattedDate += this.getDay().toString(); break;
                case "W" : sFormattedDate += sWeekOfYear; break;
                case "y" : sFormattedDate += sShortYear; break;
                case "Y" : sFormattedDate += this.getFullYear().toString(); break;
                case "z" : sFormattedDate += sDayOfYear; break;
                case "Z" : sFormattedDate += sTimezoneOffsetSeconds; break;
                default  : sFormattedDate += sChar;
            }
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sFormattedDate;
    }
}

/**
 * Returns the day of the year for this date as a one-, two-, or three-digit
 * string between "1" and "366", inclusive.
 *
 * @summary             day of year
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/12/03
 * @interface           <code>Date.getDayOfYear()</code>
 * @requires            <code>Date.isLeapYear()</code>
 * @return              the day of the year for this date as a one-, two-, or
 *                      three-digit string between "1" and "366", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              UnknownException
 * @see                 <code>Date.isLeapYear()</code>
 */
Date.prototype.getDayOfYear = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("isLeapYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.getDayOfYear", "Date.isLeapYear");
        }
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getDayOfYear", 0, iNumArguments);
        }
        var iMonth = this.getMonth();
        var sIsLeapYear = this.isLeapYear();
        if (!sIsLeapYear) {
            throw vError = new UnknownException("Date.getDayOfYear");
        }
        var iDaysInFebruary = (parseInt(sIsLeapYear) == 1) ? 29 : 28;
        var aDaysInMonth = new Array(31, iDaysInFebruary, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
        var iDayOfYear = 0;
        for (var i = 0; i < iMonth; i++) {
            iDayOfYear += aDaysInMonth[i];
        }
        iDayOfYear += this.getDate();
        var sDayOfYear = iDayOfYear.toString();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sDayOfYear;
    }
}

/**
 * Returns the number of days in the month for this date as a two-digit string
 * between "28" and "31", inclusive.
 *
 * @summary             days in month
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getDaysInMonth()</code>
 * @requires            <code>Date.isLeapYear()</code>
 * @return              the number of days in the month for this date as a
 *                      two-digit string between "28" and "31", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              UnknownException
 * @see                 <code>Date.isLeapYear()</code>
 */
Date.prototype.getDaysInMonth = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("isLeapYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.getDaysInMonth", "Date.isLeapYear");
        }
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getDaysInMonth", 0, iNumArguments);
        }
        var iMonth = this.getMonth();
        var sIsLeapYear = this.isLeapYear();
        if (!sIsLeapYear) {
            throw vError = new UnknownException("Date.getDaysInMonth");
        }
        switch (iMonth) {
            case  1 : var iDaysInMonth = (parseInt(sIsLeapYear) == 1) ? 29 : 28; break;
            case  3 :
            case  5 :
            case  8 :
            case 10 : var iDaysInMonth = 30; break;
            default : var iDaysInMonth = 31;
        }
        var sDaysInMonth = iDaysInMonth.toString();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sDaysInMonth;
    }
}

/**
 * Returns the number of days in the year for this date as either 365 or 366.
 *
 * @summary             days in year
 * @author              Stuart Wigley
 * @version             1.0, 12/01/03
 * @interface           <code>Date.getDaysInYear()</code>
 * @requires            <code>Date.isLeapYear()</code>
 * @return              the number of days in the year for this date as either
 *                      365 or 366
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              UnknownException
 * @see                 <code>Date.isLeapYear()</code>
 */
Date.prototype.getDaysInYear = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("isLeapYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.getDaysInYear", "Date.isLeapYear");
        }
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getDaysInYear", 0, iNumArguments);
        }
        var sIsLeapYear = this.isLeapYear();
        if (!sIsLeapYear) {
            throw vError = new UnknownException("Date.getDaysInYear");
        }
        var sDaysInYear = (sIsLeapYear == "1") ? "366" : "365";
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sDaysInYear;
    }
}

/**
 * Calculates the day on which Easter Sunday falls for the current year using
 * Butcher"s Method. Returns an integer between "1" and "31"
 *
 * @summary             easter day
 * @author              Stuart Wigley
 * @version             1.0, 12/01/03
 * @interface           <code>Date.getEasterDay()</code>
 * @return              the day on which Easter Sunday falls
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getEasterDay = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getEasterDate", 0, iNumArguments);
        }
        var iYear = this.getFullYear();
        var a = iYear % 19;
        var b = Math.floor(iYear / 100);
        var c = iYear % 100;
        var d = Math.floor(b / 4);
        var e = b % 4;
        var f = Math.floor((b + 8) / 25);
        var g = Math.floor((b - f + 1) / 3);
        var h = (19 * a + b - d - g + 15) % 30;
        var i = Math.floor(c / 4);
        var k = c % 4;
        var l = (32 + 2 * e + 2 * i - h - k) % 7;
        var m = Math.floor((a + 11 * h + 22 * l) / 451);
        var p = (h + l - 7 * m + 114) % 31;
        var iEasterDay = p + 1;
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : iEasterDay;
    }
}

/**
 * Calculates the month in which Easter Sunday falls for the current year using
 * Butcher"s Method. Returns "3" for March or "4" for April.
 *
 * @summary             easter month
 * @author              Stuart Wigley
 * @version             1.0, 12/01/03
 * @interface           <code>Date.getEasterMonth()</code>
 * @return              the month in which Easter Sunday falls
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getEasterMonth = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getEasterMonth", 0, iNumArguments);
        }
        var iYear = this.getFullYear();
        var a = iYear % 19;
        var b = Math.floor(iYear / 100);
        var c = iYear % 100;
        var d = Math.floor(b / 4);
        var e = b % 4;
        var f = Math.floor((b + 8) / 25);
        var g = Math.floor((b - f + 1) / 3);
        var h = (19 * a + b - d - g + 15) % 30;
        var i = Math.floor(c / 4);
        var k = c % 4;
        var l = (32 + 2 * e + 2 * i - h - k) % 7;
        var m = Math.floor((a + 11 * h + 22 * l) / 451);
        var iEasterMonth = Math.floor((h + l - 7 * m + 114) / 31);
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : iEasterMonth;
    }
}

/**
 * Returns the formatted Greenwich Mean Time (GMT) offset ("[+/-]HHMM") for
 * this date that consists of a plus sign (+) or minus sign (-) followed by
 * four digits representing hours (HH) and minutes (MM).
 *
 * @summary             GMT offset
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getGMTOffset()</code>
 * @return              the formatted Greenwich Mean Time (GMT) offset
 *                      ("[+/-]HHMM") for this date
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getGMTOffset = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getGMTOffset", 0, iNumArguments);
        }
        var iTimezoneOffset = this.getTimezoneOffset();
        var iAbsTimezoneOffset = Math.abs(iTimezoneOffset);
        var sTimezoneOffsetSign = (iTimezoneOffset != iAbsTimezoneOffset) ? "-" : "+";
        var iTimezoneOffsetHours = iAbsTimezoneOffset / 60;
        var sTempTimezoneOffsetHours = iTimezoneOffsetHours.toString();
        var sTimezoneOffsetHours = (iTimezoneOffsetHours < 10) ? "0" + sTempTimezoneOffsetHours : sTempTimezoneOffsetHours;
        var iTimezoneOffsetMinutes = iAbsTimezoneOffset % 60;
        var sTempTimezoneOffsetMinutes = iTimezoneOffsetMinutes.toString();
        var sTimezoneOffsetMinutes = (iTimezoneOffsetMinutes < 10) ? "0" + sTempTimezoneOffsetMinutes : sTempTimezoneOffsetMinutes;
        var sGMTOffset = sTimezoneOffsetSign + sTimezoneOffsetHours + sTimezoneOffsetMinutes;
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sGMTOffset;
    }
}

/**
 * Returns the hour for this date as a two-digit string between "01" and "12",
 * inclusive.
 *
 * @summary             12-hour two-digit hour (01-12)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getLong12Hours()</code>
 * @return              the hour for this date as a two-digit string between
 *                      "01" and "12", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLong12Hours = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLong12Hours", 0, iNumArguments);
        }
        var iShort12Hours = this.getHours() % 12;
        var sLong12Hours = iShort12Hours.toString();
        if (iShort12Hours == 0) {
            sLong12Hours = "12";
        } else if (iShort12Hours < 10) {
            sLong12Hours = "0" + sLong12Hours;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLong12Hours;
    }
}

/**
 * Returns the hour for this date as a two-digit string between "00" and "23",
 * inclusive.
 *
 * @summary             24-hour two-digit hour (00-23)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getLong24Hours()</code>
 * @return              the hour for this date as a two-digit string between
 *                      "00" and "23", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLong24Hours = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLong24Hours", 0, iNumArguments);
        }
        var iShort24Hours = this.getHours();
        var sLong24Hours = iShort24Hours.toString();
        if (iShort24Hours < 10) {
            sLong24Hours = "0" + sLong24Hours;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLong24Hours;
    }
}

/**
 * Returns the day of the month for this date as a two-digit string between
 * "01" and "31", inclusive.
 *
 * @summary             two-digit day of month (01-31)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getLongDate()</code>
 * @return              the day of the month for this date as a two-digit
 *                      string between "01" and "31", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLongDate = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLongDate", 0, iNumArguments);
        }
        var iShortDate = this.getDate();
        var sLongDate = iShortDate.toString();
        if (iShortDate < 10) {
            sLongDate = "0" + sLongDate;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLongDate;
    }
}

/**
 * Returns the day name for this date (e.g. "Monday", "Tuesday", etc.).
 *
 * @summary             day name
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getLongDayName()</code>
 * @return              the day name for this date
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLongDayName = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLongDayName", 0, iNumArguments);
        }
        var aLongDayNames = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
        var sLongDayName = aLongDayNames[this.getDay()];
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLongDayName;
    }
}

/**
 * Returns the minutes for this date as a two-digit string between "00" and
 * "59", inclusive.
 *
 * @summary             two-digit minutes (00-59)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getLongMinutes()</code>
 * @return              the minutes for this date as a two-digit string
 *                      between "00" and "59", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLongMinutes = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLongMinutes", 0, iNumArguments);
        }
        var iShortMinutes = this.getMinutes();
        var sLongMinutes = iShortMinutes.toString();
        if (iShortMinutes < 10) {
            sLongMinutes = "0" + sLongMinutes;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLongMinutes;
    }
}

/**
 * Returns the month for this date as a two-digit string between "01" and
 * "12", inclusive.
 *
 * @summary             two-digit month (01-12)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getLongMonth()</code>
 * @return              the month for this date as a two-digit string between
 *                      "01" and "12", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLongMonth = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLongMonth", 0, iNumArguments);
        }
        var iShortMonth = this.getMonth() + 1;
        var sLongMonth = iShortMonth.toString();
        if (iShortMonth < 10) {
            sLongMonth = "0" + sLongMonth;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLongMonth;
    }
}

/**
 * Returns the month name for this date (e.g. "January", "February", etc.).
 *
 * @summary             month name
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getLongMonthName()</code>
 * @return              the month name for this date
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLongMonthName = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLongMonthName", 0, iNumArguments);
        }
        var aLongMonthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        var sLongMonthName = aLongMonthNames[this.getMonth()];
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLongMonthName;
    }
}

/**
 * Returns the seconds for this date as a two-digit string between "00" and
 * "59", inclusive.
 *
 * @summary             two-digit seconds (00-59)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getLongSeconds()</code>
 * @return              the seconds for this date as a two-digit string
 *                      between "00" and "59", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getLongSeconds = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getLongSeconds", 0, iNumArguments);
        }
        var iShortSeconds = this.getSeconds();
        var sLongSeconds = iShortSeconds.toString();
        if (iShortSeconds < 10) {
            sLongSeconds = "0" + sLongSeconds;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sLongSeconds;
    }
}

/**
 * Returns the "meridiem" for this date as either "am" (Ante Meridiem) or "pm"
 * (Post Meridiem).
 *
 * @summary             meridiem
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getMeridiem()</code>
 * @return              the "meridiem" for this date as either "am" or "pm"
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getMeridiem = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getMeridiem", 0, iNumArguments);
        }
        var sMeridiem = (this.getHours() < 12) ? "am" : "pm";
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sMeridiem;
    }
}

/**
 * Returns the ordinal suffix (in English) of the day of the month for this
 * date (i.e. "st", "nd", "rd" or "th").
 *
 * @summary             English ordinal suffix
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getOrdinalSuffix()</code>
 * @return              the ordinal suffix (in English) of the day of the
 *                      month for this date (i.e. "st", "nd", "rd" or "th")
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getOrdinalSuffix = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getOrdinalSuffix", 0, iNumArguments);
        }
        switch (this.getDate()) {
            case  1 :
            case 21 :
            case 31 : var sOrdinalSuffix = "st"; break;
            case  2 :
            case 22 : var sOrdinalSuffix = "nd"; break;
            case  3 :
            case 23 : var sOrdinalSuffix = "rd"; break;
            default : var sOrdinalSuffix = "th";
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sOrdinalSuffix;
    }
}

/**
 * Returns this date formatted according to the Date and Time Specification of
 * RFC 822 (Standard for the Format of ARPA Internet Text Messages).
 *
 * @summary             RFC 822 date
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getRFC822Date()</code>
 * @requires            <code>Date.getGMTOffset()</code>
 * @requires            <code>Date.getLong24Hours()</code>
 * @requires            <code>Date.getLongMinutes()</code>
 * @requires            <code>Date.getLongSeconds()</code>
 * @requires            <code>Date.getShortDayName()</code>
 * @requires            <code>Date.getShortMonthName()</code>
 * @return              this date formatted according to the Date and Time
 *                      Specification of RFC 822
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              UnknownException
 * @see                 <code>Date.getGMTOffset()</code>
 * @see                 <code>Date.getLong24Hours()</code>
 * @see                 <code>Date.getLongMinutes()</code>
 * @see                 <code>Date.getLongSeconds()</code>
 * @see                 <code>Date.getShortDayName()</code>
 * @see                 <code>Date.getShortMonthName()</code>
 */
Date.prototype.getRFC822Date = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("getGMTOffset" in this)) {
            throw vError = new MethodNotAvailableException("Date.getRFC822Date", "Date.getGMTOffset");
        }
        if (!("getLong24Hours" in this)) {
            throw vError = new MethodNotAvailableException("Date.getRFC822Date", "Date.getLong24Hours");
        }
        if (!("getLongMinutes" in this)) {
            throw vError = new MethodNotAvailableException("Date.getRFC822Date", "Date.getLongMinutes");
        }
        if (!("getLongSeconds" in this)) {
            throw vError = new MethodNotAvailableException("Date.getRFC822Date", "Date.getLongSeconds");
        }
        if (!("getShortDayName" in this)) {
            throw vError = new MethodNotAvailableException("Date.getRFC822Date", "Date.getShortDayName");
        }
        if (!("getShortMonthName" in this)) {
            throw vError = new MethodNotAvailableException("Date.getRFC822Date", "Date.getShortMonthName");
        }
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getRFC822Date", 0, iNumArguments);
        }
        var sGMTOffset = this.getGMTOffset();
        var sLong24Hours = this.getLong24Hours();
        var sLongMinutes = this.getLongMinutes();
        var sLongSeconds = this.getLongSeconds();
        var sShortDayName = this.getShortDayName();
        var sShortMonthName = this.getShortMonthName();
        if (!sGMTOffset || !sLong24Hours || !sLongMinutes || !sLongSeconds || !sShortDayName || !sShortMonthName) {
            throw vError = new UnknownException("Date.getRFC822Date");
        }
        var sRFC822Date = sShortDayName + ", " + this.getDate() + " " + sShortMonthName + " " + this.getFullYear() + " " + sLong24Hours + ":" + sLongMinutes + ":" + sLongSeconds + " " + sGMTOffset;
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sRFC822Date;
    }
}

/**
 * Returns the hour for this date as a one- or two-digit string between "1"
 * and "12", inclusive.
 *
 * @summary             12-hour one-/two-digit hour (1-12)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getShort12Hours()</code>
 * @return              the hour for this date as a one- or two-digit string
 *                      between "1" and "12", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getShort12Hours = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getShort12Hours", 0, iNumArguments);
        }
        var iTempShort12Hours = this.getHours() % 12;
        var sShort12Hours = ((iTempShort12Hours == 0) ? 12 : iTempShort12Hours).toString();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sShort12Hours;
    }
}

/**
 * Returns the hour for this date as a one- or two-digit string between "0"
 * and "23", inclusive.
 *
 * @summary             24-hour one-/two-digit hour (0-23)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getShort24Hours()</code>
 * @return              the hour for this date as a one- or two-digit string
 *                      between "0" and "23", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getShort24Hours = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getShort24Hours", 0, iNumArguments);
        }
        var sShort24Hours = this.getHours().toString();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sShort24Hours;
    }
}

/**
 * Returns the shortened day name for this date (e.g. "Mon", "Tue", etc.).
 *
 * @summary             short day name
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getShortDayName()</code>
 * @requires            <code>Date.getLongDayName()</code>
 * @return              the shortened day name for this date
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              UnknownException
 * @see                 <code>Date.getLongDayName()</code>
 */
Date.prototype.getShortDayName = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("getLongDayName" in this)) {
            throw vError = new MethodNotAvailableException("Date.getShortDayName", "Date.getLongDayName");
        }
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getShortDayName", 0, iNumArguments);
        }
        var sLongDayName = this.getLongDayName();
        if (!sLongDayName) {
            throw vError = new UnknownException("Date.getShortDayName");
        }
        var sShortDayName = sLongDayName.substr(0, 3);
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sShortDayName;
    }
}

/**
 * Returns the month for this date as a one- or two-digit string between "1"
 * and "12", inclusive.
 *
 * @summary             one-/two-digit month (1-12)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getShortMonth()</code>
 * @return              the month for this date as a one- or two-digit string
 *                      between "1" and "12", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getShortMonth = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getShortMonth", 0, iNumArguments);
        }
        var sShortMonth = (this.getMonth() + 1).toString();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sShortMonth;
    }
}

/**
 * Returns the shortened month name for this date (e.g. "Jan", "Feb", etc.).
 *
 * @summary             short month name
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/17/03
 * @interface           <code>Date.getShortMonthName()</code>
 * @requires            <code>Date.getLongMonthName()</code>
 * @return              the shortened month name for this date
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              UnknownException
 * @see                 <code>Date.getLongMonthName()</code>
 */
Date.prototype.getShortMonthName = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("getLongMonthName" in this)) {
            throw vError = new MethodNotAvailableException("Date.getShortMonthName", "Date.getLongMonthName");
        }
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getShortMonthName", 0, iNumArguments);
        }
        var sLongMonthName = this.getLongMonthName();
        if (!sLongMonthName) {
            throw vError = new UnknownException("Date.getShortMonthName");
        }
        var sShortMonthName = sLongMonthName.substr(0, 3);
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sShortMonthName;
    }
}

/**
 * Returns the year for this date as a two-digit string between "00" and "99",
 * inclusive.
 *
 * @summary             two-digit year (00-99)
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getShortYear()</code>
 * @return              the year for this date as a two-digit string between
 *                      "00" and "99", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getShortYear = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getShortYear", 0, iNumArguments);
        }
        var sShortYear = this.getFullYear().toString().substr(2);
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sShortYear;
    }
}

/**
 * Returns the Swatch Internet Time for this date as a three-digit string
 * between "000" and "999" prefixed by "@". See http://www.swatch.ru for more
 * information.
 *
 * @summary             Swatch Internet Time
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/18/03
 * @interface           <code>Date.getSwatchTime()</code>
 * @return              the Swatch Internet Time for this date as a three-
 *                      digit string between "000" and "999" prefixed by "@"
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getSwatchTime = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getSwatchTime", 0, iNumArguments);
        }
        var iTempSwatchTime = Math.floor(((this.getHours() * 3600) + ((this.getMinutes() + this.getTimezoneOffset() + 60) * 60) + this.getSeconds()) / 86.4);
        var iSwatchTime = (iTempSwatchTime >= 1000) ? iTempSwatchTime - 1000 : iTempSwatchTime;
        var sSwatchTime = iSwatchTime.toString();
        if (iSwatchTime < 10) {
            sSwatchTime = "@00" + sSwatchTime;
        } else if (iSwatchTime < 100) {
            sSwatchTime = "@0" + sSwatchTime;
        } else {
            sSwatchTime = "@" + sSwatchTime;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sSwatchTime;
    }
}
/**
 * Returns the number of seconds elapsed since the UNIX epoch (1 Jan 1970
 * 00:00:00 GMT) for this date.
 *
 * @summary             seconds since UNIX epoch
 * @author              Randolph Fielding
 * @version             1.0, 08/20/03
 * @interface           <code>Date.getTimeSeconds()</code>
 * @return              the number of seconds elapsed since the UNIX epoch (1
 *                      Jan 1970 00:00:00 GMT) for this date
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getTimeSeconds = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getTimeSeconds", 0, iNumArguments);
        }
        var sTimeSeconds = Math.floor(this.getTime() / 1000).toString();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sTimeSeconds;
    }
}

/**
 * Returns the abbreviation of the name of the local timezone.
 *
 * @summary             not implemented
 * @author              Stuart Wigley
 * @version             1.0, 08/07/03
 * @interface           <code>Date.getTimezone()</code>
 * @return              the abbreviation of the name of the local timezone
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getTimezone = function() {
    return "<< NOT IMPLEMENTED >>";
}

/**
 * Returns the Greenwich Mean Time (GMT) offset for this date in seconds.
 *
 * @summary             timezone offset in seconds
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.2, 08/17/03
 * @interface           <code>Date.getTimezoneOffsetSeconds()</code>
 * @return              the Greenwich Mean Time (GMT) offset for this date in
 *                      seconds
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getTimezoneOffsetSeconds = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getTimezoneOffsetSeconds", 0, iNumArguments);
        }
        var sTimezoneOffsetSeconds = (this.getTimezoneOffset() * 60).toString();
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sTimezoneOffsetSeconds;
    }
}

/**
 * Returns the ISO week (as specified in the ISO 8601 calendar) for this date
 * as a two-digit string between "01" and "53", inclusive. The algorithm used
 * is adopted from "Algorithm for Converting Gregorian Dates to ISO 8601 Week
 * Date (Y2K Compliant)" by Rick McCarty, 1999. See
 * http://personal.ecu.edu/mccartyr/ISOwdALG.txt for more information.
 *
 * @summary             week of year
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/25/03
 * @interface           <code>Date.getWeekOfYear()</code>
 * @requires            <code>Date.getDayOfYear()</code>
 * @requires            <code>Date.isLeapYear()</code>
 * @return              the ISO week for this date as a one- or two-digit
 *                      string between "1" and "53", inclusive
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 * @throws              MethodNotAvailableException
 * @throws              UnknownException
 * @throws              <code>Date.getDayOfYear()</code>
 * @see                 <code>Date.isLeapYear()</code>
 */
Date.prototype.getWeekOfYear = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (!("getDayOfYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.getWeekOfYear", "Date.getDayOfYear");
        }
        if (!("isLeapYear" in this)) {
            throw vError = new MethodNotAvailableException("Date.getWeekOfYear", "Date.isLeapYear");
        }
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getWeekOfYear", 0, iNumArguments);
        }
        var iYear = this.getFullYear();
        var iYearM1 = iYear - 1;
        var sDayOfYear = this.getDayOfYear();
        var sIsLeapYear = this.isLeapYear();
        var sIsLeapYearM1 = (new Date("January 1, " + iYearM1.toString())).isLeapYear();
        if (!sDayOfYear || !sIsLeapYear || !sIsLeapYearM1) {
            throw vError = new UnknownException("Date.getWeekOfYear");
        }
        var iYearM1Mod100 = iYearM1 % 100;
        var iDayOfYear = parseInt(sDayOfYear);
        var iJan1DayOfWeek = 1 + ((((Math.floor((iYearM1 - iYearM1Mod100) / 100) % 4) * 5) + (iYearM1Mod100 + Math.floor(iYearM1Mod100 / 4))) % 7);
        var iDayOfWeek = 1 + (((iDayOfYear + (iJan1DayOfWeek - 1)) - 1) % 7);
        var iDaysInYear = (parseInt(sIsLeapYear) == 1) ? 366 : 365;
        var iWeekOfYear = 0;
        if ((iDayOfYear <= (8 - iJan1DayOfWeek)) && (iJan1DayOfWeek > 4)) {
            iWeekOfYear = ((iJan1DayOfWeek == 5) || ((iJan1DayOfWeek == 6) && (parseInt(sIsLeapYearM1) == 1))) ? 53 : 52;
        } else if ((iDaysInYear - iDayOfYear) < (4 - iDayOfWeek)) {
            iWeekOfYear = 1;
        } else {
            iWeekOfYear = Math.floor((iDayOfYear + (7 - iDayOfWeek) + (iJan1DayOfWeek - 1)) / 7);
            if (iJan1DayOfWeek > 4) {
                iWeekOfYear -= 1;
            }
        }
        var sWeekOfYear = iWeekOfYear.toString();
        if (iWeekOfYear < 10) {
            sWeekOfYear = "0" + sWeekOfYear;
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sWeekOfYear;
    }
}

/**
 * Returns Zodiac sign for the current date.
 *
 * @summary             zodiac sign
 * @author              Stuart Wigley
 * @version             1.0, 10/01/03
 * @interface           <code>Date.getZodiacSign()</code>
 * @return              the Zodiac sign for the current date
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.getZodiacSign = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.getZodiac", 0, iNumArguments);
        }
        var iMonth = this.getMonth() + 1;
        var iDay = this.getDate();
        var sZodiacSign = "";
        if (iMonth == 1 && iDay >= 20 || iMonth == 2 && iDay <=18) {
            sZodiacSign = "Aquarius";
        } else if (iMonth == 2 && iDay >=19 || iMonth == 3 && iDay <=20) {
            sZodiacSign = "Pisces";
        } else if (iMonth == 3 && iDay >=21 || iMonth == 4 && iDay <=19) {
            sZodiacSign = "Aries";
        } else if (iMonth == 4 && iDay >=20 || iMonth == 5 && iDay <=20) {
            sZodiacSign = "Taurus";
        } else if (iMonth == 5 && iDay >=21 || iMonth == 6 && iDay <=21) {
            sZodiacSign = "Gemini";
        } else if (iMonth == 6 && iDay >=22 || iMonth == 7 && iDay <=22) {
            sZodiacSign = "Cancer";
        } else if (iMonth == 7 && iDay >=23 || iMonth == 8 && iDay <=22) {
            sZodiacSign = "Leo";
        } else if (iMonth == 8 && iDay >=23 || iMonth == 9 && iDay <=22) {
            sZodiacSign = "Virgo";
        } else if (iMonth == 9 && iDay >=23 || iMonth == 10 && iDay <=22) {
            sZodiacSign = "Libra";
        } else if (iMonth == 10 && iDay >=23 || iMonth == 11 && iDay <=21) {
            sZodiacSign = "Scorpio";
        } else if (iMonth == 11 && iDay >=22 || iMonth == 12 && iDay <=21) {
            sZodiacSign = "Sagittarius";
        } else if (iMonth == 12 && iDay >=22 || iMonth == 1 && iDay <=19) {
            sZodiacSign = "Capricorn";
        }
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sZodiacSign;
    }
}

/**
 * Determines if this date falls within Daylight Savings Time.
 *
 * @summary             not implemented
 * @author              Stuart Wigley
 * @version             1.0, 08/07/03
 * @interface           <code>Date.isDaylightSavingsTime()</code>
 * @return              "1" if this date falls within Daylight Savings Time
 * @return              "0" if this date does not fall within Daylight Savings
 *                      Time
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.isDaylightSavingsTime = function() {
    return "<< NOT IMPLEMENTED >>";
}

/**
 * Determines if this date falls within a leap year.
 *
 * @summary             is leap year?
 * @author              Stuart Wigley
 * @author              Randolph Fielding
 * @version             1.1, 08/08/03
 * @interface           <code>Date.isLeapYear()</code>
 * @return              "1" if this date falls within a leap year
 * @return              "0" if this date does not fall within a leap year
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.isLeapYear = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.isLeapYear", 0, iNumArguments);
        }
        var iFullYear = this.getFullYear();
        var sIsLeapYear = (((iFullYear % 4) == 0) && (((iFullYear % 100) != 0) || ((iFullYear % 400) == 0))) ? "1" : "0";
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sIsLeapYear;
    }
}

/**
 * Determines if the current day is a weekday in the range Monday to Friday.
 *
 * @summary             is weekday?
 * @author              Stuart Wigley
 * @version             1.0, 10/01/03
 * @interface           <code>Date.isWeekday()</code>
 * @return              "1" if the day is a weekday
 * @return              "0" if the day is not a weekday
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.isWeekday = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.isWeekday", 0, iNumArguments);
        }
        var iDayOfWeek = this.getDay();
        var sIsWeekDay = (iDayOfWeek > 0 && iDayOfWeek < 6) ? "1" : "0";
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sIsWeekDay;
    }
}

/**
 * Determines if the current day is a weekend ie Saturday or Sunday
 *
 * @summary             is weekend?
 * @author              Stuart Wigley
 * @version             1.0, 10/01/03
 * @interface           <code>Date.isWeekend()</code>
 * @return              "1" if the day is a weekend
 * @return              "0" if the day is not a weekend
 * @return              <code>null</code> if an exception is encountered
 * @throws              IllegalArgumentException
 */
Date.prototype.isWeekend = function() {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments > 0) {
            throw vError = new IllegalArgumentException("Date.isWeekend", 0, iNumArguments);
        }
        var iDayOfWeek = this.getDay();
        var sIsWeekEnd = (iDayOfWeek == 0 || iDayOfWeek == 6) ? "1" : "0";
    }
    catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : sIsWeekEnd;
    }
}
        </script>        
        <script type="text/javascript">
            var oTest = new Test();
            var oDebug = new Debug();
            var oDate = new Date();
        </script>
    </head>
    <body>
        <table>
            <tbody>
                <tr>
                    <td>Date.formatDate()</td>
                    <td><input id="formatDate1" name="input" type="text" size="5" /></td>
                    <td><input id="formatDate" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="formatDateResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getDayOfYear()</td>
                    <td>&nbsp;</td>
                    <td><input id="getDayOfYear" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getDayOfYearResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getDaysInMonth()</td>
                    <td>&nbsp;</td>
                    <td><input id="getDaysInMonth" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getDaysInMonthResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getDaysInYear()</td>
                    <td>&nbsp;</td>
                    <td><input id="getDaysInYear" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getDaysInYearResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getEasterDay()</td>
                    <td>&nbsp;</td>
                    <td><input id="getEasterDay" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getEasterDayResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getEasterMonth()</td>
                    <td>&nbsp;</td>
                    <td><input id="getEasterMonth" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getEasterMonthResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getGMTOffset()</td>
                    <td>&nbsp;</td>
                    <td><input id="getGMTOffset" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getGMTOffsetResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLong12Hours()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLong12Hours" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLong12HoursResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLong24Hours()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLong24Hours" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLong24HoursResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLongDate()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLongDate" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLongDateResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLongDayName()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLongDayName" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLongDayNameResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLongMinutes()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLongMinutes" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLongMinutesResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLongMonth()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLongMonth" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLongMonthResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLongMonthName()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLongMonthName" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLongMonthNameResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getLongSeconds()</td>
                    <td>&nbsp;</td>
                    <td><input id="getLongSeconds" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getLongSecondsResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getMeridiem()</td>
                    <td>&nbsp;</td>
                    <td><input id="getMeridiem" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getMeridiemResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getOrdinalSuffix()</td>
                    <td>&nbsp;</td>
                    <td><input id="getOrdinalSuffix" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getOrdinalSuffixResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getRFC822Date()</td>
                    <td>&nbsp;</td>
                    <td><input id="getRFC822Date" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getRFC822DateResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getShort12Hours()</td>
                    <td>&nbsp;</td>
                    <td><input id="getShort12Hours" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getShort12HoursResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getShort24Hours()</td>
                    <td>&nbsp;</td>
                    <td><input id="getShort24Hours" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getShort24HoursResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getShortDayName()</td>
                    <td>&nbsp;</td>
                    <td><input id="getShortDayName" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getShortDayNameResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getShortMonth()</td>
                    <td>&nbsp;</td>
                    <td><input id="getShortMonth" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getShortMonthResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getShortMonthName()</td>
                    <td>&nbsp;</td>
                    <td><input id="getShortMonthName" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getShortMonthNameResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getShortYear()</td>
                    <td>&nbsp;</td>
                    <td><input id="getShortYear" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getShortYearResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getSwatchTime()</td>
                    <td>&nbsp;</td>
                    <td><input id="getSwatchTime" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getSwatchTimeResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getTimeSeconds()</td>
                    <td>&nbsp;</td>
                    <td><input id="getTimeSeconds" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getTimeSecondsResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getTimezone()</td>
                    <td>&nbsp;</td>
                    <td><input id="getTimezone" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getTimezoneResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getTimezoneOffsetSeconds()</td>
                    <td>&nbsp;</td>
                    <td><input id="getTimezoneOffsetSeconds" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getTimezoneOffsetSecondsResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getWeekOfYear()</td>
                    <td>&nbsp;</td>
                    <td><input id="getWeekOfYear" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getWeekOfYearResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.getZodiacSign()</td>
                    <td>&nbsp;</td>
                    <td><input id="getZodiacSign" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="getZodiacSignResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.isDaylightSavingsTime()</td>
                    <td>&nbsp;</td>
                    <td><input id="isDaylightSavingsTime" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="isDaylightSavingsTimeResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.isLeapYear()</td>
                    <td>&nbsp;</td>
                    <td><input id="isLeapYear" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="isLeapYearResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.isWeekday()</td>
                    <td>&nbsp;</td>
                    <td><input id="isWeekday" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="isWeekdayResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
                <tr>
                    <td>Date.isWeekend()</td>
                    <td>&nbsp;</td>
                    <td><input id="isWeekend" type="button" value="Calculate &gt;" onclick="oTest.evaluateMethod(this, "oDate")" /></td>
                    <td><input id="isWeekendResult" name="output" type="text" size="30" readonly="readonly" /></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>



Display current date: year, month day in number

<html>
<head>
</head>
<body>
<script>
    var mydate=new Date()
    var year=mydate.getYear()
    
    if (year < 1000)
        year+=1900
    
    var day=mydate.getDay()
    var month=mydate.getMonth()+1
    
    if (month<10)
        month="0"+month
    
    var daym=mydate.getDate()
    if (daym<10)
        daym="0"+daym
    
    document.write(year+"/"+month+"/"+daym)
</script>
</body>
</html>



Display date: day month year in string

<html>
<head></head>
<body>
<script>
    var mydate=new Date()
    var year=mydate.getYear()
    
    if (year < 1000)
        year+=1900
    
    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()
    
    if (daym<10)
        daym="0"+daym
        
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday",
                            "Friday","Saturday")
    var montharray=new Array("January","February","March","April","May","June",
                            "July","August","September","October","November","December")
    
    document.write(dayarray[day]+", "+montharray[month]+" "+daym+", "+year)
</script>
</body>
</html>



Display full date : complete date with the day name and month name

<html>
<body>
<script type="text/javascript">
    var d=new Date()
    var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday",
                    "Friday","Saturday")
    var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
                    "Sep","Oct","Nov","Dec")
    document.write(weekday[d.getDay()] + " ")
    document.write(d.getDate() + ". ")
    document.write(monthname[d.getMonth()] + " ")
    document.write(d.getFullYear())
</script>
</body>
</html>



Display time: continues writing time per second.

<html>
<head>
<script type="text/javascript">
var timer = null
function start(){
    var time = new Date()
    var hours = time.getHours()
    var minutes = time.getMinutes()
    minutes=((minutes < 10) ? "0" : "") + minutes
    var seconds = time.getSeconds()
    seconds=((seconds < 10) ? "0" : "") + seconds
    var clock = hours + ":" + minutes + ":" + seconds
    document.forms[0].display.value = clock
    timer = setTimeout("start()",1000)
}
</script>
</head>
<body onload="start()">
<form>
<input type="text" name="display" size="20">
</form>
</body>
</html>



Display weekday: name of the current day

/* Sunday=0, Monday=1 ... */

<html>
<body>
<script type="text/javascript">
    var d=new Date()
    var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday",
                "Friday","Saturday")
    document.write("Today is " + weekday[d.getDay()])
</script>
</body>
</html>



Extending the Date Object to Include Some New Methods

<html>
<body>
<script type="text/javascript" language="JavaScript1.1">
<!--
  Date.prototype.getActualMonth = getActualMonth;
  Date.prototype.getActualDay = getActualDay;
  Date.prototype.getCalendarDay = getCalendarDay;
  Date.prototype.getCalendarMonth = getCalendarMonth;
     function getActualMonth() {
    var n = this.getMonth();
    n += 1;
    return n;
  }
   
  function getActualDay() {
    var n = this.getDay();
    n += 1;
    return n;
  }
   
  function getCalendarDay() {
    var n = this.getDay();
    var dow = new Array(7);
    dow[0] = "Sunday";
    dow[1] = "Monday";
    dow[2] = "Tuesday";
    dow[3] = "Wednesday";
    dow[4] = "Thursday";
    dow[5] = "Friday";
    dow[6] = "Saturday";
    return dow[n];
  }
   
  function getCalendarMonth() {
    var n = this.getMonth();
    var moy = new Array(12);
    moy[0] = "January";
    moy[1] = "February";
    moy[2] = "March";
    moy[3] = "April";
    moy[4] = "May";
    moy[5] = "June";
    moy[6] = "July";
    moy[7] = "August";
    moy[8] = "September";
    moy[9] = "October";
    moy[10] = "November";
    moy[11] = "December";
    return moy[n];
  }
     // Test the new methods you created
  var today = new Date();
   
  document.write("<b>I hereby declare that on "
    + today.getCalendarDay() + ", the " + today.getDate()
    + "th day of " + today.getCalendarMonth() + " in the year "
    + today.getFullYear() + " A.D. at the " + today.getHours()
    + "th hour of the day, absolutely nothing is happening.</b>");
//-->
</script>
<body>
</html>



Get how many days before a date

<!-- 
     Example File From "JavaScript and DHTML Cookbook"
     Published by O"Reilly & Associates
     Copyright 2003 Danny Goodman
-->
 
function getDaysBefore(year, month, date) {
    var oneMinute = 60 * 1000;
    var oneHour = oneMinute * 60;
    var oneDay = oneHour * 24;
    var today = new Date();
    var targetDate = new Date();
    targetDate.setYear(year);
    targetDate.setMonth(month);
    targetDate.setDate(date);
    alert(targetDate);
    var diff = targetDate.getTime() - today.getTime();
    diff = Math.floor(diff/oneDay);
    return diff;
}



GMT Calculator

 <html>
<head>
<title>GMT Calculator</title>
<script type="text/javascript">
function calcGMT(form) {
    var date = new Date(form.year.value, form.month.value, form.date.value, 
                         form.hour.value, form.minute.value, form.second.value);
    form.output.value = date.toUTCString();
}
</script>
</head>
<body>
<form>
<b>Enter a local date/time</b><br>
Year:<input type="text" name="year" value="0000"><br>
Month (0-11):<input type="text" name="month" value="0"><br>
Date (1-31):<input type="text" name="date" value="0"><br>
Hour (0-23):<input type="text" name="hour" value="0"><br>
Minute (0-59):<input type="text" name="minute" value="0"><br>
Second (0-59):<input type="text" name="second" value="0"><br>
<input type="button" value="Get GMT" onclick="calcGMT(this.form)"><br>
GMT: <input type="text" name="output" size="60">
</body>
</html>



how many days Between two dates

<!-- 
     Example File From "JavaScript and DHTML Cookbook"
     Published by O"Reilly & Associates
     Copyright 2003 Danny Goodman
-->

function daysBetween(date1, date2) {
    var DSTAdjust = 0;
    // constants used for our calculations below
    oneMinute = 1000 * 60;
    var oneDay = oneMinute * 60 * 24;
    // equalize times in case date objects have them
    date1.setHours(0);
    date1.setMinutes(0);
    date1.setSeconds(0);
    date2.setHours(0);
    date2.setMinutes(0);
    date2.setSeconds(0);
    // take care of spans across Daylight Saving Time changes
    if (date2 > date1) {
        DSTAdjust = 
            (date2.getTimezoneOffset() - date1.getTimezoneOffset()) * oneMinute;
    } else {
        DSTAdjust = 
            (date1.getTimezoneOffset() - date2.getTimezoneOffset()) * oneMinute;    
    }
    var diff = Math.abs(date2.getTime() - date1.getTime()) - DSTAdjust;
    return Math.ceil(diff/oneDay);
}

var projectLength = 0;
// validate form entries with checkDate() function from Recipe 2.12
var startField = document.entryForm.startDate;
var endField = document.entryForm.endDate;
if (checkDate(startField) && checkDate(endField)) {
    var startDate = new Date(startField.value);
    var endDate = new Date(endField.value);
    projectLength = daysBetween(startDate, endDate);
}
if (projectLength > 0) {
    alert("You\"ve specified " + projectLength + " days for this project.");
}



How Many Days Until Christmas

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 
John Wiley & Sons CopyRight 2001
*/
<HTML>
<HEAD>
<TITLE>Christmas Countdown</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function getDaysUntilXmas() {
    var oneMinute = 60 * 1000
    var oneHour = oneMinute * 60
    var oneDay = oneHour * 24
    var today = new Date()
    var nextXmas = new Date()
    nextXmas.setMonth(11)
    nextXmas.setDate(25)
    if (today.getMonth() == 11 && today.getDate() > 25) {
        nextXmas.setFullYear(nextXmas.getFullYear() + 1)
    }
    var diff = nextXmas.getTime() - today.getTime()
    diff = Math.floor(diff/oneDay)
    return diff
}
</SCRIPT>
</HEAD>
<BODY>
<H1>
<SCRIPT LANGUAGE="JavaScript">
var header = "You have <I>" + getDaysUntilXmas()  + "</I> "
header += "shopping days until Christmas."
document.write(header)
</SCRIPT>
</H1><HR>
</BODY>
</HTML>



Methods and Properties of the Date Object

Method
getDate()        Returns the date within month (1 to 31).
getDay()         Returns the day within the week (0 to 6).
getFullYear()    Returns the year in local time with four digits. 
getHours()       Returns the hour within the day (0 to 23).
getMilliseconds()  Returns the milliseconds.
getMinutes()      Returns the minutes within the hour (0 to 59).
getMonth()        Returns the month within the year (0 to 11).
getSeconds()      Returns seconds within the minute (0 to 59).
getTime()         Returns the number of milliseconds since 1/1/70 00:00:00.
getTimeZoneOffset()  Returns minutes offset from GMT/UTC.
getUTCDate()      Returns the day of the month.
getUTCDay()       Returns the day of the week converted to universal time.
getUTCFullYear()  Returns a four-digit representation of the year converted to universal time.
getUTCHours()     Returns the hour converted to universal time.
getUTCMilliseconds()Returns the milliseconds converted to universal time. 
getUTCMinutes()   Returns the minutes converted to universal time. 
getUTCMonth()    Returns the month converted to universal time.
getUTCSeconds()   Returns the seconds converted to universal time. 
getYear()        Returns number of years since 1900.
parse()          Converts the passed-in string date to milliseconds.
setDate()        Sets the date within the month (1 to 31).
setFullYear()     Sets the year as a four-digit number.
setHours()        Sets hour within day (0 to 23).
setMilliseconds()  Sets the milliseconds.
setMinutes()     Sets the minutes within the hour (0 to 59).
setMonth()       Sets the month within the year (0 to 11).
setSeconds()     Sets the seconds within the minute (0 to 59).
setTime()        Sets the number of milliseconds since 1/1/70 00:00:00.
setUTCdate()     Sets the day of the month in universal time. 
setUTCFullYear()   Sets the year as a four-digit number in universal time.
setUTCHours()     Sets the hour in universal time.
setUTCMilliseconds()  Sets the milliseconds in universal time.
setUTCMinutes()   Sets the minutes in universal time.
setUTCMonth()    Sets the month in universal time.
setUTCSeconds()   Sets the seconds in universal time.
setYear()         Sets the number of years since 1900.
toGMTString()    Returns the date string in universal format.
toLocalString()    Returns the date string in the local system"s format.
toSource()        Returns the source of the Date object.
toString()        Returns the date and time as a string in local time.
toUTCString()     Returns the data and time as a string in universal time (UTC). 
UTC()             Convertscomma-delimited values to milliseconds of UTC date.
valueOf()         Returns the equivalence of the Date object in milliseconds.
Property
prototype         Property that allows you to add methods and properties to the Date object.



Output day

<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript"><!--
 var today = new Date()
 adIX = today.getDay()
 document.write(adIX)
// --></SCRIPT>
</body>
</HTML>



Set date: setDate, setHour

<html>
<body>
<script type="text/javascript">
    var d = new Date()
    
    d.setFullYear("2005")
    document.write(d)
</script>
</body>
</html>



Simple Date Validation

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 
John Wiley & Sons CopyRight 2001
*/

<HTML>
<HEAD>
<TITLE>Simple Date Validation</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function validDate(fld) {
    var testMo, testDay, testYr, inpMo, inpDay, inpYr, msg
    var inp = fld.value
    status = ""
    // attempt to create date object from input data
    var testDate = new Date(inp)
    // extract pieces from date object
    testMo = testDate.getMonth() + 1
    testDay = testDate.getDate()
    testYr = testDate.getFullYear()
    // extract components of input data
    inpMo = parseInt(inp.substring(0, inp.indexOf("/")), 10)
    inpDay = parseInt(inp.substring((inp.indexOf("/") + 1), inp.lastIndexOf("/")), 10)
    inpYr = parseInt(inp.substring((inp.lastIndexOf("/") + 1), inp.length), 10)
    // make sure parseInt() succeeded on input components
    if (isNaN(inpMo) || isNaN(inpDay) || isNaN(inpYr)) {
        msg = "There is some problem with your date entry."
    }
    // make sure conversion to date object succeeded
    if (isNaN(testMo) || isNaN(testDay) || isNaN(testYr)) {
        msg = "Couldn"t convert your entry to a valid date. Try again."
    }
    // make sure values match
    if (testMo != inpMo || testDay != inpDay || testYr != inpYr) {
        msg = "Check the range of your date value."
    }
    if (msg) {
        // there"s a message, so something failed
        alert(msg)
        // work around IE timing problem with alert by
        // invoking a focus/select function through setTimeout();
        // must pass along reference of fld (as string)
        setTimeout("doSelection(document.forms["" + 
        fld.form.name + ""].elements["" + fld.name + ""])", 0)
        return false
    } else {
        // everything"s OK; if browser supports new date method,
        // show just date string in status bar
        status = (testDate.toLocaleDateString) ? testDate.toLocaleDateString() : 
            "Date OK"
        return true
    }
}
// separate function to accommodate IE timing problem
function doSelection(fld) {
    fld.focus()
    fld.select()
}
</SCRIPT>
</HEAD>
<BODY>
<H1>Simple Date Validation</H1>
<HR>
<FORM NAME="entryForm" onSubmit="return false">
Enter any date (mm/dd/yyyy): <INPUT TYPE="text" NAME="startDate" 
    onChange="validDate(this)">
</FORM>
</BODY>
</HTML>



Summer Games Countdown

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 
John Wiley & Sons CopyRight 2001
*/
<HTML>
<HEAD>
<TITLE>Summer Games Countdown</TITLE>
<SCRIPT LANGUAGE="JavaScript">
// globals -- calculate only once
// set target date to 1700GMT on August 13, 2004
var targetDate = Date.UTC(2010, 7, 13, 17, 0, 0, 0)
var oneMinute = 60 * 1000
var oneHour = oneMinute * 60
var oneDay = oneHour * 24
function getTimeUntil(targetMS) {
    var today = new Date()
    var diff = targetMS - today.valueOf()
    return Math.floor(diff)
}
function getCountDown() {
    var ms = getTimeUntil(targetDate)
    var output = ""
    var days, hrs, mins, secs
    if (ms >= 0) {
        days = Math.floor(ms/oneDay)
        ms -= oneDay * days
        hrs = Math.floor(ms/oneHour)
        ms -= oneHour * hrs
        mins = Math.floor(ms/oneMinute)
        ms -= oneMinute * mins
        secs = Math.floor(ms/1000)
        output += days + " Days, " + 
                  hrs + " Hours, " +
                  mins + " Minutes, " +
                  secs + " Seconds"
    } else {
        output += "The time has passed."
    }
    return output
}
function updateCountDown() {
    document.forms[0].timer.value = getCountDown()
    setTimeout("updateCountDown()", 1000)
}
</SCRIPT>
</HEAD>
<BODY onLoad="updateCountDown()">
<H1>Athens Games Torch Lighting Countdown</H1>
<P>
<SCRIPT LANGUAGE="JavaScript">
if (navigator.userAgent.indexOf("Win") >= 0) {
    document.write("(" + (new Date(targetDate)).toLocaleString())
    document.write(" in your time zone.)")
}
</SCRIPT>
</P>
<FORM>
<INPUT TYPE="text" NAME="timer" SIZE=60>
</FORM>
<HR>
</BODY>
</HTML>



Today"s Date

/*
Examples From
JavaScript: The Definitive Guide, Fourth Edition
Legal matters: these files were created by David Flanagan, and are
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and
distribute them for any purpose.  Please note that these examples are
provided "as-is" and come with no warranty of any kind.
David Flanagan
*/
<html>
<head>
<title>Today"s Date</title>
    <script language="JavaScript">
    // Define a function for use later on.
    function print_todays_date() {
        var d = new Date();                  // Get today"s date and time
        document.write(d.toLocaleString());  // Insert it into the document
    }
    </script>
</head>
<body>
The date and time are:<br>
<script language="JavaScript">
  // Now call the function we defined above.
  print_todays_date();
</script>
</body>
</html>



Using the Date Object

<HTML>
<HEAD>
<TITLE>Using the Date Object Type</TITLE>
</HEAD>
<BODY>
<H1>Using the Date Object Type</H1>
<SCRIPT LANGUAGE="JavaScript"><!--
currentDate = new Date()
with (currentDate) {
 document.write("Date: "+(getMonth()+1)+"/"+getDate()+"/"+getFullYear() +"<BR>")
 document.write("Time: "+getHours()+":"+getMinutes()+":" +getSeconds())
}
// --></SCRIPT>
</BODY>
</HTML>



UTC time: getUTCDate returns the Universal Coordinated Time

/* the time set by the World Time Standard.*/
<html>
<body>
<script type="text/javascript">
    var d = new Date()
    
    document.write(d.getUTCHours())
    document.write(".")
    document.write(d.getUTCMinutes())
    document.write(".")
    document.write(d.getUTCSeconds())
</script>
</body>
</html>