Skip to content

Commit

Permalink
Fix a time picker bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dangrossman committed Dec 17, 2015
1 parent 7d85c53 commit 87b3b4b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
26 changes: 20 additions & 6 deletions daterangepicker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @version: 2.1.14
* @version: 2.1.15
* @author: Dan Grossman http://www.dangrossman.info/
* @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
Expand Down Expand Up @@ -850,11 +850,25 @@
//Preserve the time already selected
var timeSelector = this.container.find('.calendar.right .calendar-time div');
if (timeSelector.html() != '') {
selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
if (selected.isAfter(maxDate))
selected = maxDate.clone();

selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());

if (!this.timePicker24Hour) {
var ampm = timeSelector.find('.ampmselect option:selected').val();
if (ampm === 'PM' && selected.hour() < 12)
selected.hour(selected.hour() + 12);
if (ampm === 'AM' && selected.hour() === 12)
selected.hour(0);
}

if (selected.isBefore(this.startDate))
selected = this.startDate.clone();

if (selected.isAfter(maxDate))
selected = maxDate.clone();

}
}

Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'dangrossman:bootstrap-daterangepicker',
version: '2.1.14',
version: '2.1.15',
summary: 'Date range picker component for Bootstrap',
git: 'https://github.com/dangrossman/bootstrap-daterangepicker',
documentation: 'README.md'
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.1.14",
"version": "2.1.15",
"description": "Date range picker component for Bootstrap",
"main": "daterangepicker.js",
"style": "daterangepicker.css",
Expand Down

0 comments on commit 87b3b4b

Please sign in to comment.