function lneSetDefaultDate() { // Set date field default to today var strNow = new Date(); document.forms[0].txtDayFrom.value = strNow.getDate(); document.forms[0].lstMonthFrom.selectedIndex = strNow.getMonth(); document.forms[0].txtYearFrom.value = strNow.getFullYear(); document.forms[0].txtDayTo.value = strNow.getDate(); document.forms[0].lstMonthTo.selectedIndex = strNow.getMonth(); document.forms[0].txtYearTo.value = strNow.getFullYear(); return true; } function stdDateCalc(strDate) { if ((strDate != "") && (strDate != "ALL")) { dateBase = new Date(); strPeriod = strDate.substring(2, 4); if (strDate.substring(0, 1) == "B") intDelta = 10; else intDelta = strDate.substring(0, 1); if (strPeriod == "WK") { intDelta *= 7; intDelta--; dateBase.setDate(dateBase.getDate() - intDelta); } if (strPeriod == "MO") dateBase.setMonth(dateBase.getMonth() - intDelta); if (strPeriod == "YR") dateBase.setYear(dateBase.getYear() - intDelta); strDate = (dateBase.getMonth() + 1) + "/" + dateBase.getDate() + "/" + dateBase.getFullYear(); } return strDate; } function enhDateCalc(strDate, boolFrom) { var aryMonthNames = new Array("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"); var boolTextMonth = false; var intMonth; var intDay; var intYear; var strDateOrig = strDate; var aryResults; for (i = 0; i <= (strDate.length - 3); i++) { for (j = 0; j < 12; j++) { if (strDate.substring(i, i + 3).toLowerCase() == aryMonthNames[j]) { if (i != 0) { if ((strDate.charAt(i - 1).toLowerCase() < "a") || (strDate.charAt(i - 1).toLowerCase() > "z")) { boolTextMonth = true; break; } } else { boolTextMonth = true; break; } } } if (boolTextMonth) break; } if (boolTextMonth) { intMonth = j; aryResults = parseForNumber(strDate); intDay = aryResults[0]; } else { aryResults = parseForNumber(strDate); intMonth = --aryResults[0]; if (aryResults[1] == "") return "INVALID"; aryResults = parseForNumber(aryResults[1]); intDay = aryResults[0]; } if (aryResults[1] == "") intYear = ""; else { aryResults = parseForNumber(aryResults[1]); intYear = aryResults[0]; } if (intYear == "") { intYear = intDay; intDay = -1; } if ((intYear.length != 2) && (intYear.length != 4)) return "INVALID"; if (intYear.length == 2) { if ((dateNow.getYear() >= 100) && ((dateNow.getYear() - 100) >= intYear)) return "Y2K"; else intYear = "19" + intYear; } if (intDay == -1) { if (boolFrom) intDay = 1; else { var dateEnd = new Date(intYear, intMonth + 1, 0); intDay = dateEnd.getDate(); } } var dateTest = new Date(intYear, intMonth, intDay); if ((dateTest.getMonth() != intMonth) || (dateTest.getDate() != intDay) || (dateTest.getFullYear() != intYear)) return "INVALID"; strDate = (dateTest.getMonth() + 1) + "/" + dateTest.getDate() + "/" + dateTest.getFullYear(); return strDate; } function parseForNumber(strDate) { var boolFound = false; var aryResults = new Array(0, strDate); var intLen = strDate.length; for (i = 0; i < intLen; i++) if ((strDate.charAt(i) >= "0") && (strDate.charAt(i) <= "9")) { boolFound = true; break; } if (boolFound) { strDate = strDate.substring(i, intLen + 1); if (i == intLen - 1) { aryResults[0] = strDate; aryResults[1] = ""; } else { for (i = 0; i < strDate.length; i++) if ((strDate.charAt(i) < "0") || (strDate.charAt(i) > "9")) break; aryResults[0] = strDate.substring(0, i); if (i != strDate.length - 1) aryResults[1] = strDate.substring(i, strDate.length + 1); } } return aryResults; }