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
@ -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');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user