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.com> |
* +-------------------------------------------------------------------------+
* $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.com> |
* +-------------------------------------------------------------------------+
* $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.com> |
* +-------------------------------------------------------------------------+
* $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.com> |
* +-------------------------------------------------------------------------+
* $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.com 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 >" 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> </td>
<td><input id="getDayOfYear" type="button" value="Calculate >" 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> </td>
<td><input id="getDaysInMonth" type="button" value="Calculate >" 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> </td>
<td><input id="getDaysInYear" type="button" value="Calculate >" 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> </td>
<td><input id="getEasterDay" type="button" value="Calculate >" 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> </td>
<td><input id="getEasterMonth" type="button" value="Calculate >" 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> </td>
<td><input id="getGMTOffset" type="button" value="Calculate >" 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> </td>
<td><input id="getLong12Hours" type="button" value="Calculate >" 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> </td>
<td><input id="getLong24Hours" type="button" value="Calculate >" 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> </td>
<td><input id="getLongDate" type="button" value="Calculate >" 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> </td>
<td><input id="getLongDayName" type="button" value="Calculate >" 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> </td>
<td><input id="getLongMinutes" type="button" value="Calculate >" 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> </td>
<td><input id="getLongMonth" type="button" value="Calculate >" 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> </td>
<td><input id="getLongMonthName" type="button" value="Calculate >" 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> </td>
<td><input id="getLongSeconds" type="button" value="Calculate >" 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> </td>
<td><input id="getMeridiem" type="button" value="Calculate >" 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> </td>
<td><input id="getOrdinalSuffix" type="button" value="Calculate >" 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> </td>
<td><input id="getRFC822Date" type="button" value="Calculate >" 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> </td>
<td><input id="getShort12Hours" type="button" value="Calculate >" 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> </td>
<td><input id="getShort24Hours" type="button" value="Calculate >" 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> </td>
<td><input id="getShortDayName" type="button" value="Calculate >" 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> </td>
<td><input id="getShortMonth" type="button" value="Calculate >" 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> </td>
<td><input id="getShortMonthName" type="button" value="Calculate >" 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> </td>
<td><input id="getShortYear" type="button" value="Calculate >" 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> </td>
<td><input id="getSwatchTime" type="button" value="Calculate >" 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> </td>
<td><input id="getTimeSeconds" type="button" value="Calculate >" 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> </td>
<td><input id="getTimezone" type="button" value="Calculate >" 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> </td>
<td><input id="getTimezoneOffsetSeconds" type="button" value="Calculate >" 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> </td>
<td><input id="getWeekOfYear" type="button" value="Calculate >" 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> </td>
<td><input id="getZodiacSign" type="button" value="Calculate >" 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> </td>
<td><input id="isDaylightSavingsTime" type="button" value="Calculate >" 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> </td>
<td><input id="isLeapYear" type="button" value="Calculate >" 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> </td>
<td><input id="isWeekday" type="button" value="Calculate >" 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> </td>
<td><input id="isWeekend" type="button" value="Calculate >" onclick="oTest.evaluateMethod(this, 'oDate')" /></td>
<td><input id="isWeekendResult" name="output" type="text" size="30" readonly="readonly" /></td>
</tr>
</tbody>
</table>
</body>
</html>
Related examples in the same category