mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
added parsing of time like from 0315 => 03:15
This commit is contained in:
parent
94263f6b22
commit
e1c36b440b
@ -989,16 +989,28 @@
|
||||
input
|
||||
.off('blur.xdsoft')
|
||||
.on('blur.xdsoft', function () {
|
||||
if (options.allowBlank && !$.trim($(this).val()).length) {
|
||||
$(this).val(null);
|
||||
datetimepicker.data('xdsoft_datetime').empty();
|
||||
} else if (!Date.parseDate($(this).val(), options.format)) {
|
||||
$(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');
|
||||
if (options.allowBlank && !$.trim($(this).val()).length) {
|
||||
$(this).val(null);
|
||||
datetimepicker.data('xdsoft_datetime').empty();
|
||||
} 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));
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user