日期:2009-09-10  浏览次数:20861 次

  this.GetTextDate = function(theString){ //convert a string to a date, if the string is not a date, return a empty string

    var i = 0, j = 0, tmpChar = "", find_tag = "";
    var start_at = 0, end_at = 0, year_at = 0, month_at = 0, day_at = 0;
    var tmp_at = 0, one_at = 0, two_at = 0, one_days = 0, two_days = 0;
    var aryDate = new Array();
    var tmpYear = -1, tmpMonth = -1, tmpDay = -1;
    var tmpDate = theString.toLowerCase();
    var defDate = "";
    tmpDate = tmpDate.replace(/(\D)0(\d)/g, "$1-$2");
    for (i = 0; i < 9; i++){
      tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), "-00" + (i+1).toString() + "-");
    }
    for (i = 9; i < 12; i++){
      tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), "-0" + (i+1).toString() + "-");
    }
    tmpDate = tmpDate.replace(/jan/g, "-001-");
    tmpDate = tmpDate.replace(/feb/g, "-002-");
    tmpDate = tmpDate.replace(/mar/g, "-003-");
    tmpDate = tmpDate.replace(/apr/g, "-004-");
    tmpDate = tmpDate.replace(/may/g, "-005-");
    tmpDate = tmpDate.replace(/jun/g, "-006-");
    tmpDate = tmpDate.replace(/jul/g, "-007-");
    tmpDate = tmpDate.replace(/aug/g, "-008-");
    tmpDate = tmpDate.replace(/sep/g, "-009-");
    tmpDate = tmpDate.replace(/oct/g, "-010-");
    tmpDate = tmpDate.replace(/nov/g, "-011-");
    tmpDate = tmpDate.replace(/dec/g, "-012-");
    for (i = 0; i < tmpDate.length; i++){
      tmpChar = tmpDate.charAt(i);
      if (((tmpChar < "0") || (tmpChar>"9")) && (tmpChar != "-")){
        tmpDate = tmpDate.replace(tmpChar, "-")
      }
    }
    while (tmpDate.indexOf("--") != -1){
      tmpDate = tmpDate.replace(/--/g, "-");
    }
    start_at = 0;
    end_at = tmpDate.length-1;
    while (tmpDate.charAt(start_at) == "-"){
      start_at++;
    }
    while (tmpDate.charAt(end_at) == "-"){
      end_at--;
    }
    if (start_at < end_at+1){
      tmpDate = tmpDate.substring(start_at, end_at + 1);
    }else{
      tmpDate = "";
    }
    aryDate = tmpDate.split("-");
    if (aryDate.length != 3){
 &nbs