//   2.1 短时间,形如 (13:04:06) 
      function isTime(str) 
      { 
        var a = str.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d{1,2})$/); 
        if (a == null) {alert('输入的参数不是时间格式'); return false;} 
        if (a[1]>24 || a[3]>60 || a[4]>60) 
        { 
          alert("时间格式不对"); 
          return false 
        } 
        return true; 
      } 
  //2.2 短日期,形如 (2003-12-05) 
      function strDateTime(str) 
      { 
         var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); 
         if(r==null)return false; 
         var d= new Date(r[1], r[3]-1, r[4]); 
         return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]); 
      } 
  //2.3 长时间,形如 (2003-12-05 13:04:06) 
      function strDateTime(str) 
      { 
        var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
        var r = str.match(reg); 
        if(r==null)return false; 
        var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); 
        return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]); 
      }
                function TimeCom( dateValue )
    {
        var newCom = new Date( dateValue );
        this.year = newCom.getYear();
        this.month = newCom.getMonth()+1;
        this.day = newCom.getDate();
        this.hour = newCom.getHours();
        this.minute = newCom.getMinutes();
        this.second = newCom.getSeconds();
        this.msecond = newCom.getMilliseconds();
        this.week = newCom.getDay();
    }    function DateDiff(interval,date1,date2)
    {
        var TimeCom1 = new TimeCom(date1);
        var TimeCom2 = new TimeCom(date2);
        var result;
        switch(String(interval).toLowerCase())
        {
            case "y":
            case "year":
            result = TimeCom1.year-TimeCom2.year;
            break;
            case "n":
            case "month":
            result = (TimeCom1.year-TimeCom2.year)*12+(TimeCom1.month-TimeCom2.month);
            break;
            case "d":
            case "day":
            result = Math.round((Date.UTC(TimeCom1.year,TimeCom1.month-1,TimeCom1.day)-Date.UTC(TimeCom2.year,TimeCom2.month-1,TimeCom2.day))/(1000*60*60*24));
            break;
            case "h":
            case "hour":
            result = Math.round((Date.UTC(TimeCom1.year,TimeCom1.month-1,TimeCom1.day,TimeCom1.hour)-Date.UTC(TimeCom2.year,TimeCom2.month-1,TimeCom2.day,TimeCom2.hour))/(1000*60*60));
            break;
            case "m":
            case "minute":
            result = Math.round((Date.UTC(TimeCom1.year,TimeCom1.month-1,TimeCom1.day,TimeCom1.hour,TimeCom1.minute)-Date.UTC(TimeCom2.year,TimeCom2.month-1,TimeCom2.day,TimeCom2.hour,TimeCom2.minute))/(1000*60));
            break;
            case "s":
            case "second":
            result = Math.round((Date.UTC(TimeCom1.year,TimeCom1.month-1,TimeCom1.day,TimeCom1.hour,TimeCom1.minute,TimeCom1.second)-Date.UTC(TimeCom2.year,TimeCom2.month-1,TimeCom2.day,TimeCom2.hour,TimeCom2.minute,TimeCom2.second))/1000);
            break;
            case "ms":
            case "msecond":
            result = Date.UTC(TimeCom1.year,TimeCom1.month-1,TimeCom1.day,TimeCom1.hour,TimeCom1.minute,TimeCom1.second,TimeCom1.msecond)-Date.UTC(TimeCom2.year,TimeCom2.month-1,TimeCom2.day,TimeCom2.hour,TimeCom2.minute,TimeCom2.second,TimeCom1.msecond);
            break;
            case "w":
            case "week":
            result = Math.round((Date.UTC(TimeCom1.year,TimeCom1.month-1,TimeCom1.day)-Date.UTC(TimeCom2.year,TimeCom2.month-1,TimeCom2.day))/(1000*60*60*24)) % 7;
            break;
            default:
            result = "invalid";
        }
        return(result);
    }
function DateAdd(interval, num, dateValue)
{
var r;
switch(String(interval).toLowerCase())
{
case "y": case "year":
r = new Date(dateValue.getYear() + num,dateValue.getMonth(),dateValue.getDate(),dateValue.getHours(),dateValue.getMinutes(),dateValue.getSeconds(),dateValue.getMilliseconds());break;
            case "n": case "month":
r = new Date(dateValue.getYear(),dateValue.getMonth() + num,dateValue.getDate(),dateValue.getHours(),dateValue.getMinutes(),dateValue.getSeconds(),dateValue.getMilliseconds());break;
case "d": case "day":
r = new Date(dateValue.getYear(),dateValue.getMonth(),dateValue.getDate() + num,dateValue.getHours(),dateValue.getMinutes(),dateValue.getSeconds(),dateValue.getMilliseconds());break;
            case "h": case "hour":
r = new Date(dateValue.getYear(),dateValue.getMonth(),dateValue.getDate(),dateValue.getHours()+num,dateValue.getMinutes(),dateValue.getSeconds(),dateValue.getMilliseconds());break;
            case "m": case "minute":
r = new Date(dateValue.getYear(),dateValue.getMonth(),dateValue.getDate(),dateValue.getHours(),dateValue.getMinutes()+num,dateValue.getSeconds(),dateValue.getMilliseconds());break;
            case "s": case "second":
r = new Date(dateValue.getYear(),dateValue.getMonth(),dateValue.getDate(),dateValue.getHours(),dateValue.getMinutes(),dateValue.getSeconds()+num,dateValue.getMilliseconds());break;
            case "ms": case "msecond":
             r = new Date(dateValue.getYear(),dateValue.getMonth(),dateValue.getDate(),dateValue.getHours(),dateValue.getMinutes(),dateValue.getSeconds(),dateValue.getMilliseconds()+num);break;
            case "w": case "week":
             r = new Date(dateValue.getYear(),dateValue.getMonth(),dateValue.getDate()+num*7,dateValue.getHours(),dateValue.getMinutes(),dateValue.getSeconds(),dateValue.getMilliseconds());break;
default: return("invalid");
}
return(r);
}