Fix date bug in JS that makes dates not work with strings

This commit is contained in:
Jacob Schatz 2017-06-13 14:53:40 -04:00
parent 6c26fb353a
commit e73cfbd46a

View file

@ -168,6 +168,7 @@ class DueDateSelectors {
initMilestoneDatePicker() {
$('.datepicker').each(function() {
const $datePicker = $(this);
const [y, m, d] = $datePicker.val().split('-');
const calendar = new Pikaday({
field: $datePicker.get(0),
theme: 'gitlab-theme animate-picker',
@ -177,7 +178,8 @@ class DueDateSelectors {
$datePicker.val(dateFormat(new Date(dateText), 'yyyy-mm-dd'));
}
});
calendar.setDate(new Date($datePicker.val()));
calendar.setDate(new Date(y, m-1, d));
$datePicker.data('pikaday', calendar);
});