added parsing of time like from 0315 => 03:15

This commit is contained in:
Ihor Kroosh 2014-12-10 12:46:37 +02:00
parent 94263f6b22
commit e1c36b440b

View File

@ -993,11 +993,23 @@
$(this).val(null); $(this).val(null);
datetimepicker.data('xdsoft_datetime').empty(); datetimepicker.data('xdsoft_datetime').empty();
} else if (!Date.parseDate($(this).val(), options.format)) { } else if (!Date.parseDate($(this).val(), options.format)) {
var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
// parse the numbers as 0312 => 03:12
if(!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
$(this).val([splittedHours, splittedMinutes].map(function(item) {
return item > 9 ? item : '0' + item
}).join(':'));
} else {
$(this).val((_xdsoft_datetime.now()).dateFormat(options.format)); $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
}
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
} else { } else {
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
} }
datetimepicker.trigger('changedatetime.xdsoft'); datetimepicker.trigger('changedatetime.xdsoft');
}); });
} }