Skip to content

Commit

Permalink
[BugFix] 修改取得input的时间出现的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
linlingyu committed Apr 20, 2012
1 parent d1fdba1 commit 73857b2
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/baidu/ui/DatePicker.js
Expand Up @@ -64,24 +64,20 @@ baidu.ui.DatePicker = baidu.ui.createUI(function(options){
*/
_getInputDate: function(){
var me = this,
dateValue = me.input.value,
patrn = [/yyyy|yy/, /M{1,2}/, /d{1,2}/],//只支持到年月日的格式化,需要时分秒的请扩展此数组
key = [],
val = {},
count = patrn.length,
i = 0,
regExp;
for(; i < count; i++){
regExp = patrn[i].exec(me.format);
key[i] = regExp ? regExp.index : null;
len = patrn.length,
date = [],
regExp,
index;
if(!dateValue){return;}
for(var i = 0; i < len; i++){
if(regExp = patrn[i].exec(me.format)){
index = regExp.index;
date[i] = dateValue.substring(index, index + regExp[0].length);
}
}
me.input.value.replace(/\d{1,4}/g, function(mc, index){
val[index] = mc;
});
for(i = 0; i < key.length; i++){
key[i] = val[key[i]];
if(!key[i]){return;}
}
return new Date(key[0], key[1] - 1, key[2]);//需要时分秒的则扩展参数
return new Date(date[0], date[1] - 1, date[2]);//需要时分秒的则扩展参数
},

/**
Expand Down

0 comments on commit 73857b2

Please sign in to comment.