Skip to content

Commit

Permalink
Merge pull request #2 from kyleshay/single-date
Browse files Browse the repository at this point in the history
Only show 1 date if start + end are same.
  • Loading branch information
mike-guerrette authored Sep 13, 2016
2 parents d9f20db + 7b66622 commit b3dbb8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions daterangepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@

// If the end of the range is before the minimum or the start of the range is
// after the maximum, don't display this range option at all.
if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
|| (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
continue;

Expand Down Expand Up @@ -448,7 +448,7 @@
// if attached to a text input, set the initial value
//

if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput && this.startDate.diff(this.endDate, 'days') !== 0) {
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
this.element.trigger('change');
} else if (this.element.is('input') && this.autoUpdateInput) {
Expand Down Expand Up @@ -652,7 +652,7 @@
curDate = moment([year, 0, 1]);
if (side == 'right') {
if (this.leftCalendar.month.year() === this.rightCalendar.month.year()) {
curDate = curDate.add('year', 1);
curDate = curDate.add(1, 'year');
}
}
//initialize a 3 rows x 4 columns array for the calendar
Expand Down Expand Up @@ -1581,7 +1581,7 @@
this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active');
$(e.target).addClass('active');

// Set the state such that if the user goes back to using a mouse,
// Set the state such that if the user goes back to using a mouse,
// the calendars are aware we're selecting the end of the range, not
// the start. This allows someone to edit the end of a date range without
// re-selecting the beginning, by clicking on the end date input then
Expand Down Expand Up @@ -1647,7 +1647,7 @@
},

updateElement: function() {
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput && this.startDate.diff(this.endDate, 'days') !== 0) {
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
this.element.trigger('change');
} else if (this.element.is('input') && this.autoUpdateInput) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-daterangepicker",
"version": "2.2.0",
"version": "2.2.1",
"description": "Date range picker component for Bootstrap",
"main": "daterangepicker.js",
"style": "daterangepicker.css",
Expand Down

0 comments on commit b3dbb8e

Please sign in to comment.