[BUGFIX] DatePicker can't handle minDate and maxDate 92/36892/3
authorNicole Cordes <typo3@cordes.co>
Fri, 13 Feb 2015 22:46:40 +0000 (23:46 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Sat, 14 Feb 2015 14:07:25 +0000 (15:07 +0100)
The Bootstrap DatePicker expects the min and max dates to be formatted
in the format defined in the options. Currently both dates are filled
with an unix timestamp. These can't be converted to a date object (moment
object) and the date picker is completely disabled.

This patch adds the conversion of unix timestamp to the right format
before the Bootstrap DatePicker is initialized.

Releases: master
Resolves: #65068
Change-Id: Ie8143efb537067dd89cfb42aa477f63b8c07f693
Reviewed-on: http://review.typo3.org/36892
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/backend/Resources/Public/JavaScript/DateTimePicker.js

index 4e3c9ad..55c7d67 100644 (file)
@@ -82,6 +82,14 @@ define('TYPO3/CMS/Backend/DateTimePicker', ['jquery'], function ($) {
                                                        break;
                                        }
 
+                                       // datepicker expects the min and max dates to be formatted with options.format but unix timestamp given
+                                       if ($element.data('dateMindate')) {
+                                               $element.data('dateMindate', moment.unix($element.data('dateMindate')).format(options.format));
+                                       }
+                                       if ($element.data('dateMaxdate')) {
+                                               $element.data('dateMaxdate', moment.unix($element.data('dateMaxdate')).format(options.format));
+                                       }
+
                                        // initialize the date time picker on this element
                                        $element.datetimepicker(options);
                                });