Arian : Mootools-datepicker : Parse date with the option format first (propose on github https://github.com/arian/mootools-datepicker/pull/50)

This commit is contained in:
Benjamin Renard 2011-06-27 12:05:56 +02:00
parent de2336f68e
commit 10ef09c5e7

View file

@ -115,7 +115,10 @@ this.DatePicker = Picker.Date = new Class({
} }
this.date = new Date(); this.date = new Date();
if (input){ if (input){
var date = Date.parse(input.get('value')); var date = Date.parse(input.get('value'),options.format);
if (date == null){
date = Date.parse(input.get('value'));
}
if (date == null || !date.isValid()){ if (date == null || !date.isValid()){
var storeDate = input.retrieve('datepicker:value'); var storeDate = input.retrieve('datepicker:value');
if (storeDate) date = Date.parse(storeDate); if (storeDate) date = Date.parse(storeDate);