Skip to content

Commit 3708e1f

Browse files
committed
Fix unwanted behavior when modifying time on the Date value
Since time was reset to 0 because of a bug on boostrap-datepicker, you were not able to bind the component value on a Date object were you would change its time value. This fixes it with cloning the date object sent to the bootstrap datepicker object.
1 parent 6e6c7b9 commit 3708e1f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

addon/components/datepicker-support.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default Ember.Mixin.create({
137137
dates = [null];
138138
}
139139
dates = dates.map(function(date) {
140-
return (Ember.isNone(date)) ? null : self._resetTime(date);
140+
return (Ember.isNone(date)) ? null : self._getDateCloneWithNoTime(date);
141141
});
142142

143143
element.datepicker
@@ -147,12 +147,14 @@ export default Ember.Mixin.create({
147147
// HACK: Have to reset time to 00:00:00 because of the bug in
148148
// bootstrap-datepicker
149149
// Issue: http://git.io/qH7Hlg
150-
_resetTime: function(date) {
151-
date.setHours(0);
152-
date.setMinutes(0);
153-
date.setSeconds(0);
154-
date.setMilliseconds(0);
150+
_getDateCloneWithNoTime: function(date) {
151+
var clone = new Date(date.getTime());
155152

156-
return date;
153+
clone.setHours(0);
154+
clone.setMinutes(0);
155+
clone.setSeconds(0);
156+
clone.setMilliseconds(0);
157+
158+
return clone;
157159
}
158160
});

0 commit comments

Comments
 (0)