Skip to content

Commit 05bf0fe

Browse files
committed
Another attempt at fixing the time picker bug
1 parent 4a86db9 commit 05bf0fe

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

daterangepicker.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @version: 2.1.16
2+
* @version: 2.1.17
33
* @author: Dan Grossman http://www.dangrossman.info/
44
* @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
55
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
@@ -488,6 +488,8 @@
488488
if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
489489
this.endDate = this.startDate.clone().add(this.dateLimit);
490490

491+
this.previousRightTime = this.endDate.clone();
492+
491493
if (!this.isShowing)
492494
this.updateElement();
493495

@@ -844,7 +846,7 @@
844846
selected = this.startDate.clone();
845847
minDate = this.minDate;
846848
} else if (side == 'right') {
847-
selected = this.endDate ? this.endDate.clone() : this.startDate.clone();
849+
selected = this.endDate ? this.endDate.clone() : this.previousRightTime.clone();
848850
minDate = this.startDate;
849851

850852
//Preserve the time already selected
@@ -1086,6 +1088,7 @@
10861088

10871089
this.oldStartDate = this.startDate.clone();
10881090
this.oldEndDate = this.endDate.clone();
1091+
this.previousRightTime = this.endDate.clone();
10891092

10901093
this.updateView();
10911094
this.container.show();
@@ -1278,7 +1281,7 @@
12781281
// * if single date picker mode, and time picker isn't enabled, apply the selection immediately
12791282
//
12801283

1281-
if (this.endDate || date.isBefore(this.startDate)) {
1284+
if (this.endDate || date.isBefore(this.startDate, 'day')) {
12821285
if (this.timePicker) {
12831286
var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
12841287
if (!this.timePicker24Hour) {
@@ -1294,6 +1297,10 @@
12941297
}
12951298
this.endDate = null;
12961299
this.setStartDate(date.clone());
1300+
} else if (!this.endDate && date.isBefore(this.startDate)) {
1301+
//special case: clicking the same date for start/end,
1302+
//but the time of the end date is before the start date
1303+
this.setEndDate(this.startDate.clone());
12971304
} else {
12981305
if (this.timePicker) {
12991306
var hour = parseInt(this.container.find('.right .hourselect').val(), 10);

package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package.describe({
22
name: 'dangrossman:bootstrap-daterangepicker',
3-
version: '2.1.16',
3+
version: '2.1.17',
44
summary: 'Date range picker component for Bootstrap',
55
git: 'https://github.com/dangrossman/bootstrap-daterangepicker',
66
documentation: 'README.md'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bootstrap-daterangepicker",
3-
"version": "2.1.16",
3+
"version": "2.1.17",
44
"description": "Date range picker component for Bootstrap",
55
"main": "daterangepicker.js",
66
"style": "daterangepicker.css",

0 commit comments

Comments
 (0)