jonthornton / Datepair.js

A javascript plugin for intelligently selecting date and time ranges, inspired by Google Calendar.
https://www.jonthornton.com/Datepair.js
359 stars 85 forks source link

Date formatting was not obeying the 'format' option for datepicker #1

Closed asgeo1 closed 10 years ago

asgeo1 commented 10 years ago

Date formatting was not working - only yyyy-mm-dd format (the default) was working previously.

This PR should fix that so it obeys the format from the datepicker() widget.

Also... now you no longer need the base.js file which had the Date.format function, and "parseDate" function which aren't really needed. datepicker() has it's own date formatting stuff which should be enough.

Also, why bundle datepicker() in the base.js ? Can't it be included via bower? You're doing that for the timepicker...

asgeo1 commented 10 years ago

Also note that this fix works with bootstrap datepicker 1.1. If you update to the laster 1.3 version, then you need to change

$dateInput.data('datepicker').date;

to

$dateInput.data('datepicker').viewDate;
jonthornton commented 10 years ago

Thanks for the pull! The plugin isn't finished yet (I should have noted that in the readme; updated now), so there are definitely some rough edges that need work.

My plan regarding the formatting is to allow developers to pass in callback functions to perform the formatting - what you see in the jquery.datepair.js are just defaults. This abstracts out all of the datepicker/timepicker code so that you can use your UI component of choice with datepicker.

I'll revisit this when I'm getting the plugin ready for release.