text: 
  
  u.date= {
      /**
       * 多语言处理
       */
      //TODO 后续放到多语文件中
      _dateLocale:{
          'zh-CN':{
              months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
              monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
              weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
              weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
              weekdaysMin : '日_一_二_三_四_五_六'.split('_')
          },
          'en-US':{
              months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
              monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
              weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thurday_Friday_Saturday'.split('_'),
              weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
              weekdaysMin : 'S_M_T_W_T_F_S'.split('_')
          }
      },
  
      _formattingTokens : /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYY|YY|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g,
  
      leftZeroFill : function(number, targetLength, forceSign) {
          var output = '' + Math.abs(number),sign = number >= 0;
          while (output.length < targetLength) {
              output = '0' + output;
          }
          return (sign ? (forceSign ? '+' : '') : '-') + output;
      },
  
      _formats: {
          //year
          YY   : function (date) {
              return u.date.leftZeroFill(date.getFullYear() % 100, 2);
          },
          YYYY : function (date) {
              return date.getFullYear();
          },
          //month
          M : function (date) {
              return date.getMonth() + 1;
          },
          MM: function(date){
              var m = u.date._formats.M(date);
              return u.date.leftZeroFill(m,2);
          },
          MMM  : function (date, language) {
              var m = date.getMonth();
              return u.date._dateLocale[language].monthsShort[m];
          },
          MMMM : function (date, language) {
              var m = date.getMonth();
              return u.date._dateLocale[language].months[m];
          },
          //date
          D : function (date) {
              return date.getDate();
          },
          DD: function(date){
              var d = u.date._formats.D(date);
              return u.date.leftZeroFill(d,2);
          },
          // weekday
          d : function (date) {
              return date.getDay();
          },
          dd : function (date, language) {
              var d = u.date._formats.d(date);
              return u.date._dateLocale[language].weekdaysMin[d];
          },
          ddd : function (date, language) {
              var d = u.date._formats.d(date);
              return u.date._dateLocale[language].weekdaysShort[d];
          },
          dddd : function (date, language) {
              var d = u.date._formats.d(date);
              return u.date._dateLocale[language].weekdays[d];
          },
          // am pm
          a: function(date){
              if (date.getHours() > 12){
                  return 'pm';
              }else{
                  return 'am';
              }
          },
          //hour
          h: function(date){
              var h = date.getHours();
              h = h > 12 ? h-12 : h;
              return h
          },
          hh: function(date){
              var h = u.date._formats.h(date);
              return u.date.leftZeroFill(h,2);
          },
          H: function(date){
              return date.getHours();
          },
          HH: function(date){
              return u.date.leftZeroFill(date.getHours(),2);
          },
          // minutes
          m: function(date){
              return date.getMinutes();
          },
          mm: function(date){
              return u.date.leftZeroFill(date.getMinutes(), 2);
          },
          //seconds
          s: function(date){
              return date.getSeconds();
          },
          ss: function(date){
              return u.date.leftZeroFill(date.getSeconds(),2);
          }
      },
  
      /**
       * 日期格式化
       * @param date
       * @param formatString
       */
      format: function(date, formatString, language){
          if (!date) return date;
          var array = formatString.match(u.date._formattingTokens), i, length,output='';
          var _date = u.date.getDateObj(date);
          if (!_date) return date;
          language = language || u.core.getLanguages();
          for (i = 0, length = array.length; i < length; i++) {
              if (u.date._formats[array[i]]) {
                  output += u.date._formats[array[i]](_date, language);
              } else {
                  output += array[i];
              }
          }
          return output;
      },
  
      _addOrSubtract: function(date, period, value, isAdding){
          var times = date.getTime(),d = date.getDate(), m = date.getMonth(),_date = u.date.getDateObj(date);
          if (period === 'ms') {
              times = times + value * isAdding;
              _date.setTime(times);
          }
          else if (period == 's') {
              times = times + value*1000 * isAdding;
              _date.setTime(times);
          }
          else if (period == 'm') {
              times = times + value*60000 * isAdding;
              _date.setTime(times);
          }
          else if (period == 'h') {
              times = times + value*3600000 * isAdding;
              _date.setTime(times);
          }
          else if (period == 'd') {
              d = d + value * isAdding;
              _date.setDate(d);
          }
          else if (period == 'w') {
              d = d + value * 7 * isAdding;
              _date.setDate(d);
          }
          else if (period == 'M') {
              m = m + value * isAdding;
              _date.setMonth(d);
          }
          else if (period == 'y'){
              m = m + value * 12 * isAdding;
              _date.setMonth(d);
          }
          return _date;
      },
  
      add: function(date,period,value){
          return u.date._addOrSubtract(date, period, value, 1);
      },
      sub: function(date,period,value){
          return u.date._addOrSubtract(date, period, value, -1);
      },
      getDateObj: function(value){
          if (!value || typeof value == 'undefined') return value;
          var dateFlag = false;
          var _date = new Date(value);
          if (isNaN(_date)){
              // IE的话对"2016-2-13 12:13:22"进行处理
              var index1,index2,index3,s1,s2,s3;
              if(value.indexOf){
                  index1 = value.indexOf('-');
                  index2 = value.indexOf(':');
                  index3 = value.indexOf(' ');
                  if(index1 > 0 || index2 > 0 || index3 > 0){
                      _date = new Date();
                      if(index3 > 0){
                          s3 = value.split(' ');
                          s1 = s3[0].split('-');
                          s2 = s3[1].split(':'); 
                      }else if(index1 > 0){
                          s1 = value.split('-');
                      }else if(index2 > 0){
                          s2 = value.split(':');
                      }
                      if(s1 && s1.length > 0){
                          _date.setYear(s1[0]);
                          _date.setMonth(parseInt(s1[1] -1));
                          _date.setDate(s1[2]?s1[2]:0);
                          dateFlag = true;
                      }
                      if(s2 && s2.length > 0){
                          _date.setHours(s2[0]?s2[0]:0);
                          _date.setMinutes(s2[1]?s2[1]:0);
                          _date.setSeconds(s2[2]?s2[2]:0);
                          dateFlag = true;
                      }
                  }else{
                      _date = new Date(parseInt(value))
                      if (isNaN(_date)) {
                          throw new TypeError('invalid Date parameter');
                      }else{
                          dateFlag = true;
                      }
                  }
              }
          }else{
              dateFlag = true;
          }
  
          if(dateFlag)
              return _date;
          else
              return null;
      }
  };
  
  