Skip to content

Commit 396e4d5

Browse files
committed
Fix #109 - set time new and old always the same due to scope.ngModel = newDate; #109
1 parent b96f4e4 commit 396e4d5

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Angular bootstrap date & time picker v0.3.1
1+
# Angular bootstrap date & time picker v0.3.2
22
================================
33

44
Native AngularJS datetime picker directive styled by Twitter Bootstrap 3

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-bootstrap-datetimepicker",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "This directive allows you to add a datetime-picker to your form.",
55
"author": "https://github.com/dalelotts/angular-bootstrap-datetimepicker/graphs/contributors",
66
"license": "MIT",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-bootstrap-datetimepicker",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "This directive allows you to add a datetime-picker to your form elements.",
55
"author": "https://github.com/dalelotts/ng-bootstrap-datetimepicker/graphs/contributors",
66
"license": "MIT",

src/css/datetimepicker.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @license angular-bootstrap-datetimepicker v0.3.1
3-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
2+
* @license angular-bootstrap-datetimepicker v0.3.2
3+
* (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
44
* License: MIT
55
*/
66

src/js/datetimepicker.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/*jslint vars:true */
33

44
/**
5-
* @license angular-bootstrap-datetimepicker v0.3.1
6-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* @license angular-bootstrap-datetimepicker v0.3.2
6+
* (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
77
* License: MIT
88
*/
99

@@ -301,13 +301,14 @@ angular.module('ui.bootstrap.datetimepicker', [])
301301
var tempDate = new Date(unixDate);
302302
var newDate = new Date(tempDate.getTime() + (tempDate.getTimezoneOffset() * 60000));
303303

304+
var oldDate = scope.ngModel;
304305
scope.ngModel = newDate;
305306

306307
if (configuration.dropdownSelector) {
307308
jQuery(configuration.dropdownSelector).dropdown('toggle');
308309
}
309310

310-
scope.onSetTime({ newDate: newDate, oldDate: scope.ngModel });
311+
scope.onSetTime({ newDate: scope.ngModel, oldDate: oldDate });
311312

312313
return dataFactory[configuration.startView](unixDate);
313314
}

test/configuration/onSetTime.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,24 @@ describe('onSetTime', function () {
5858
selectedElement.trigger('click');
5959
});
6060
});
61+
62+
63+
describe('accepts additional parameter for onSetTime', function () {
64+
it('if onSetTime is not a function', function () {
65+
66+
$rootScope.setTimeFunction = function (index, oldDate, newDate) {
67+
expect(oldDate).toBe(null);
68+
expect(oldDate).not.toEqual(newDate);
69+
expect(newDate).toEqual(moment("2020-01-01T00:00:00.000").toDate());
70+
console.log(index);
71+
};
72+
73+
var element = $compile('<datetimepicker data-ng-model=\'date\' data-on-set-time=\'setTimeFunction(3, oldDate, newDate, "foo")\' data-datetimepicker-config="{ startView: \'year\', minView: \'year\' }" ></datetimepicker>')($rootScope);
74+
$rootScope.$digest();
75+
76+
var selectedElement = jQuery('.future', element);
77+
selectedElement.trigger('click');
78+
});
79+
});
6180
});
6281

0 commit comments

Comments
 (0)