tempusdominus / bootstrap-4

Tempus Dominus Bootstrap 4 Datetime Picker
https://getdatepicker.com/5-4/
MIT License
611 stars 239 forks source link

Error reading localeData #376

Open mdellanave opened 2 years ago

mdellanave commented 2 years ago

I found an unhandled exception if I try to set locale on an empty date picker jQuery('#myDTP').datetimepicker('locale', 'it');

This is the code that throw the error

this.actualFormat = format.replace(/(\[[^\[]*])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) {
        return (self.isInitFormatting && self._options.date === null ? self.getMoment() : self._dates[0]).localeData().longDateFormat(formatInput) || formatInput; //todo taking the first date should be ok
      });

it could be simply solved adding the ? (self.isInitFormatting && self._options.date === null ? self.getMoment() : self._dates[0])**?**.localeData()