diff options
-rw-r--r-- | app/assets/javascripts/due_date_select.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/datefix.js | 9 |
2 files changed, 13 insertions, 4 deletions
diff --git a/app/assets/javascripts/due_date_select.js b/app/assets/javascripts/due_date_select.js index 7a47a85c4fd..60da9bff06c 100644 --- a/app/assets/javascripts/due_date_select.js +++ b/app/assets/javascripts/due_date_select.js @@ -2,6 +2,8 @@ /* global dateFormat */ /* global Pikaday */ +import DateFix from './lib/utils/datefix' + class DueDateSelect { constructor({ $dropdown, $loading } = {}) { const $dropdownParent = $dropdown.closest('.dropdown'); @@ -50,7 +52,6 @@ class DueDateSelect { format: 'yyyy-mm-dd', onSelect: (dateText) => { const formattedDate = dateFormat(new Date(dateText), 'yyyy-mm-dd'); - $dueDateInput.val(formattedDate); if (this.$dropdown.hasClass('js-issue-boards-due-date')) { @@ -62,7 +63,7 @@ class DueDateSelect { } }); - calendar.setDate(new Date($dueDateInput.val())); + calendar.setDate(DateFix.dashedFix($dueDateInput.val())); this.$datePicker.append(calendar.el); this.$datePicker.data('pikaday', calendar); } @@ -168,7 +169,6 @@ 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', @@ -179,7 +179,7 @@ class DueDateSelectors { } }); - calendar.setDate(new Date(y, m - 1, d)); + calendar.setDate(DateFix.dashedFix($datePicker.val())); $datePicker.data('pikaday', calendar); }); diff --git a/app/assets/javascripts/lib/utils/datefix.js b/app/assets/javascripts/lib/utils/datefix.js new file mode 100644 index 00000000000..d0c81ec854f --- /dev/null +++ b/app/assets/javascripts/lib/utils/datefix.js @@ -0,0 +1,9 @@ +const DateFix = { + dashedFix(val) { + const [y, m, d] = val.split('-'); + console.log(y,m,d) + return new Date(y, m - 1, d); + } +} + +export default DateFix;
\ No newline at end of file |