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

@ -989,16 +989,28 @@
input input
.off('blur.xdsoft') .off('blur.xdsoft')
.on('blur.xdsoft', function () { .on('blur.xdsoft', function () {
if (options.allowBlank && !$.trim($(this).val()).length) { if (options.allowBlank && !$.trim($(this).val()).length) {
$(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)) {
$(this).val((_xdsoft_datetime.now()).dateFormat(options.format)); var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
} else {
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); // parse the numbers as 0312 => 03:12
} if(!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
datetimepicker.trigger('changedatetime.xdsoft'); $(this).val([splittedHours, splittedMinutes].map(function(item) {
return item > 9 ? item : '0' + item
}).join(':'));
} else {
$(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
}
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
} else {
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
}
datetimepicker.trigger('changedatetime.xdsoft');
}); });
} }
options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1; options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;