Skip to content

Commit a4427e1

Browse files
committed
Merge branch 'release/0.3.9'
2 parents 1f54161 + d9d18f6 commit a4427e1

23 files changed

+354
-60
lines changed

.travis.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
language: node_js
22
node_js:
3-
- "0.10"
4-
3+
- '0.12'
54
branches:
65
except:
7-
- gh-pages
8-
6+
- gh-pages
97
before_install:
10-
- "export DISPLAY=:99.0"
11-
- "sh -e /etc/init.d/xvfb start"
12-
8+
- export DISPLAY=:99.0
9+
- sh -e /etc/init.d/xvfb start
1310
before_script:
14-
- npm install -g bower grunt-cli
15-
- bower install
16-
17-
script: "grunt --verbose"
11+
- npm install -g bower grunt-cli
12+
- bower install
13+
script: grunt --verbose
14+
deploy:
15+
provider: npm
16+
email: dale@dalelotts.com
17+
api_key:
18+
secure: uS3oRid+vZK5nKVqd5YNhAJGyNbJAdw0/3gHZB67ynG9HWEr1Y026uzf0Ext6XT9LHjCgGPEaN1Lyjr+LJRYt+LV7HYDVm09RrEIqJm+2+2qwQIpVtxRyr6xCr1b2EFFrYqwZPe33/Y0WradbaqQ0EKLBSygCNL8tzC7b1yxD6U=
19+
on:
20+
tags: true
21+
repo: dalelotts/angular-bootstrap-datetimepicker
22+
branch: master

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Angular bootstrap date & time picker version: 0.3.8
1+
# Angular bootstrap date & time picker version: 0.3.10
22
================================
33

44
Native AngularJS datetime picker directive styled by Twitter Bootstrap 3
@@ -127,7 +127,8 @@ The following parameters are supplied by this directive :
127127

128128
```
129129
DateObject {
130-
dateValue: Number - UTC time value of this date object - same as moment.valueOf() or Date.getTime(). It does NOT contain time zone information so take that into account when comparing to other dates.
130+
utcDateValue: Number - UTC time value of this date object. It does NOT contain time zone information so take that into account when comparing to other dates (or use localDateValue function).
131+
localDateValue: FUNCTION that returns a Number - local time value of this date object - same as moment.valueOf() or Date.getTime().
131132
display: String - the way this value will be displayed on the calendar.
132133
active: true | false | undefined - indicates that date object is part of the model value.
133134
selectable: true | false | undefined - indicates that date value is selectable by the user.

bower.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-bootstrap-datetimepicker",
3-
"version": "0.3.8",
3+
"version": "0.3.10",
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",
@@ -23,12 +23,12 @@
2323
"test*"
2424
],
2525
"dependencies": {
26-
"angular": "1.2.26",
26+
"angular": "~1.3.14",
2727
"moment": "^2.8.4"
2828
},
2929
"devDependencies": {
30-
"angular-mocks": "1.2.26",
31-
"bootstrap": "^3.1.1",
32-
"jquery": "^2.1.1"
30+
"angular-mocks": "~1.3.14",
31+
"bootstrap": "^3.3.1",
32+
"jquery": "^2.1.3"
3333
}
3434
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-bootstrap-datetimepicker",
3-
"version": "0.3.8",
3+
"version": "0.3.10",
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
"bugs": {
@@ -18,7 +18,7 @@
1818
"grunt-contrib-jshint": "^0.10.0",
1919
"grunt-istanbul-coverage": "^0.1.0",
2020
"grunt-karma": "^0.9.0",
21-
"gulp": "^3.8.10",
21+
"gulp": "^3.8.11",
2222
"gulp-bump": "^0.1.11",
2323
"gulp-jshint": "^1.9.0",
2424
"gulp-plato": "^1.0.1",

src/css/datetimepicker.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license angular-bootstrap-datetimepicker version: 0.3.8
2+
* @license angular-bootstrap-datetimepicker version: 0.3.10
33
* (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
44
* License: MIT
55
*/

src/js/datetimepicker.js

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*jslint vars:true */
33

44
/**
5-
* @license angular-bootstrap-datetimepicker version: 0.3.8
5+
* @license angular-bootstrap-datetimepicker version: 0.3.10
66
* (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
77
* License: MIT
88
*/
@@ -16,7 +16,7 @@
1616
(function (factory) {
1717
'use strict';
1818
/* istanbul ignore if */
19-
if (typeof define === 'function' && /* istanbul ignore next */ define.amd) {
19+
if (typeof define === 'function' && /* istanbul ignore next */ define.amd) {
2020
define(['angular', 'moment'], factory); // AMD
2121
} else {
2222
factory(window.angular, window.moment); // Browser global
@@ -34,10 +34,16 @@
3434

3535
function DateObject() {
3636

37-
this.dateValue = new Date().getTime();
37+
var tempDate = new Date();
38+
var localOffset = tempDate.getTimezoneOffset() * 60000;
39+
this.utcDateValue = tempDate.getTime();
3840
this.selectable = true;
3941

40-
var validProperties = ['dateValue', 'display', 'active', 'selectable', 'past', 'future'];
42+
this.localDateValue = function () {
43+
return this.utcDateValue + localOffset;
44+
};
45+
46+
var validProperties = ['utcDateValue', 'localDateValue', 'display', 'active', 'selectable', 'past', 'future'];
4147

4248
for (var prop in arguments[0]) {
4349
/* istanbul ignore else */
@@ -97,7 +103,7 @@
97103
restrict: 'E',
98104
require: 'ngModel',
99105
template: '<div class="datetimepicker table-responsive">' +
100-
'<table class="table table-striped">' +
106+
'<table class="table table-striped {{ data.currentView }}-view">' +
101107
' <thead>' +
102108
' <tr>' +
103109
' <th class="left" data-ng-click="changeView(data.currentView, data.leftDate, $event)" data-ng-show="data.leftDate.selectable"><i class="glyphicon glyphicon-arrow-left"/></th>' +
@@ -163,16 +169,16 @@
163169
var result = {
164170
'currentView': 'year',
165171
'nextView': configuration.minView === 'year' ? 'setTime' : 'month',
166-
'previousViewDate': new DateObject({dateValue: null, display: startDecade + '-' + (startDecade + 9)}),
167-
'leftDate': new DateObject({dateValue: moment.utc(startDate).subtract(9, 'year').valueOf()}),
168-
'rightDate': new DateObject({dateValue: moment.utc(startDate).add(11, 'year').valueOf()}),
172+
'previousViewDate': new DateObject({utcDateValue: null, display: startDecade + '-' + (startDecade + 9)}),
173+
'leftDate': new DateObject({utcDateValue: moment.utc(startDate).subtract(9, 'year').valueOf()}),
174+
'rightDate': new DateObject({utcDateValue: moment.utc(startDate).add(11, 'year').valueOf()}),
169175
'dates': []
170176
};
171177

172178
for (var i = 0; i < 12; i += 1) {
173179
var yearMoment = moment.utc(startDate).add(i, 'years');
174180
var dateValue = {
175-
'dateValue': yearMoment.valueOf(),
181+
'utcDateValue': yearMoment.valueOf(),
176182
'display': yearMoment.format('YYYY'),
177183
'past': yearMoment.year() < startDecade,
178184
'future': yearMoment.year() > startDecade + 9,
@@ -196,18 +202,18 @@
196202
'currentView': 'month',
197203
'nextView': configuration.minView === 'month' ? 'setTime' : 'day',
198204
'previousViewDate': new DateObject({
199-
dateValue: previousViewDate.valueOf(),
205+
utcDateValue: previousViewDate.valueOf(),
200206
display: startDate.format('YYYY')
201207
}),
202-
'leftDate': new DateObject({dateValue: moment.utc(startDate).subtract(1, 'year').valueOf()}),
203-
'rightDate': new DateObject({dateValue: moment.utc(startDate).add(1, 'year').valueOf()}),
208+
'leftDate': new DateObject({utcDateValue: moment.utc(startDate).subtract(1, 'year').valueOf()}),
209+
'rightDate': new DateObject({utcDateValue: moment.utc(startDate).add(1, 'year').valueOf()}),
204210
'dates': []
205211
};
206212

207213
for (var i = 0; i < 12; i += 1) {
208214
var monthMoment = moment.utc(startDate).add(i, 'months');
209215
var dateValue = {
210-
'dateValue': monthMoment.valueOf(),
216+
'utcDateValue': monthMoment.valueOf(),
211217
'display': monthMoment.format('MMM'),
212218
'active': monthMoment.format('YYYY-MMM') === activeDate
213219
};
@@ -234,11 +240,11 @@
234240
'currentView': 'day',
235241
'nextView': configuration.minView === 'day' ? 'setTime' : 'hour',
236242
'previousViewDate': new DateObject({
237-
dateValue: previousViewDate.valueOf(),
243+
utcDateValue: previousViewDate.valueOf(),
238244
display: startOfMonth.format('YYYY-MMM')
239245
}),
240-
'leftDate': new DateObject({dateValue: moment.utc(startOfMonth).subtract(1, 'months').valueOf()}),
241-
'rightDate': new DateObject({dateValue: moment.utc(startOfMonth).add(1, 'months').valueOf()}),
246+
'leftDate': new DateObject({utcDateValue: moment.utc(startOfMonth).subtract(1, 'months').valueOf()}),
247+
'rightDate': new DateObject({utcDateValue: moment.utc(startOfMonth).add(1, 'months').valueOf()}),
242248
'dayNames': [],
243249
'weeks': []
244250
};
@@ -253,7 +259,7 @@
253259
for (var j = 0; j < 7; j += 1) {
254260
var monthMoment = moment.utc(startDate).add((i * 7) + j, 'days');
255261
var dateValue = {
256-
'dateValue': monthMoment.valueOf(),
262+
'utcDateValue': monthMoment.valueOf(),
257263
'display': monthMoment.format('D'),
258264
'active': monthMoment.format('YYYY-MMM-DD') === activeDate,
259265
'past': monthMoment.isBefore(startOfMonth),
@@ -278,18 +284,18 @@
278284
'currentView': 'hour',
279285
'nextView': configuration.minView === 'hour' ? 'setTime' : 'minute',
280286
'previousViewDate': new DateObject({
281-
dateValue: previousViewDate.valueOf(),
287+
utcDateValue: previousViewDate.valueOf(),
282288
display: selectedDate.format('ll')
283289
}),
284-
'leftDate': new DateObject({dateValue: moment.utc(selectedDate).subtract(1, 'days').valueOf()}),
285-
'rightDate': new DateObject({dateValue: moment.utc(selectedDate).add(1, 'days').valueOf()}),
290+
'leftDate': new DateObject({utcDateValue: moment.utc(selectedDate).subtract(1, 'days').valueOf()}),
291+
'rightDate': new DateObject({utcDateValue: moment.utc(selectedDate).add(1, 'days').valueOf()}),
286292
'dates': []
287293
};
288294

289295
for (var i = 0; i < 24; i += 1) {
290296
var hourMoment = moment.utc(selectedDate).add(i, 'hours');
291297
var dateValue = {
292-
'dateValue': hourMoment.valueOf(),
298+
'utcDateValue': hourMoment.valueOf(),
293299
'display': hourMoment.format('LT'),
294300
'active': hourMoment.format('YYYY-MM-DD H') === activeFormat
295301
};
@@ -310,11 +316,11 @@
310316
'currentView': 'minute',
311317
'nextView': 'setTime',
312318
'previousViewDate': new DateObject({
313-
dateValue: previousViewDate.valueOf(),
319+
utcDateValue: previousViewDate.valueOf(),
314320
display: selectedDate.format('lll')
315321
}),
316-
'leftDate': new DateObject({dateValue: moment.utc(selectedDate).subtract(1, 'hours').valueOf()}),
317-
'rightDate': new DateObject({dateValue: moment.utc(selectedDate).add(1, 'hours').valueOf()}),
322+
'leftDate': new DateObject({utcDateValue: moment.utc(selectedDate).subtract(1, 'hours').valueOf()}),
323+
'rightDate': new DateObject({utcDateValue: moment.utc(selectedDate).add(1, 'hours').valueOf()}),
318324
'dates': []
319325
};
320326

@@ -323,7 +329,7 @@
323329
for (var i = 0; i < limit; i += 1) {
324330
var hourMoment = moment.utc(selectedDate).add(i * configuration.minuteStep, 'minute');
325331
var dateValue = {
326-
'dateValue': hourMoment.valueOf(),
332+
'utcDateValue': hourMoment.valueOf(),
327333
'display': hourMoment.format('LT'),
328334
'active': hourMoment.format('YYYY-MM-DD H:mm') === activeFormat
329335
};
@@ -362,8 +368,8 @@
362368
event.preventDefault();
363369
}
364370

365-
if (viewName && (dateObject.dateValue > -Infinity) && dateObject.selectable && dataFactory[viewName]) {
366-
var result = dataFactory[viewName](dateObject.dateValue);
371+
if (viewName && (dateObject.utcDateValue > -Infinity) && dateObject.selectable && dataFactory[viewName]) {
372+
var result = dataFactory[viewName](dateObject.utcDateValue);
367373

368374
var weekDates = [];
369375
if (result.weeks) {
@@ -389,7 +395,7 @@
389395
};
390396

391397
ngModelController.$render = function $render() {
392-
scope.changeView(configuration.startView, new DateObject({dateValue: getUTCTime(ngModelController.$viewValue)}));
398+
scope.changeView(configuration.startView, new DateObject({utcDateValue: getUTCTime(ngModelController.$viewValue)}));
393399
};
394400
}
395401
};

test/configuration/beforeRender.spec.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ describe('beforeRender', function () {
8181

8282
$rootScope.beforeRender = function (dates) {
8383
expect(dates.length).toBe(42);
84-
expect(dates[0].dateValue).toBe(1388275200000);
85-
expect(dates[11].dateValue).toBe(1389225600000);
84+
expect(dates[0].utcDateValue).toBe(1388275200000);
85+
expect(dates[0].localDateValue()).toBe(1388293200000);
86+
expect(dates[11].utcDateValue).toBe(1389225600000);
87+
expect(dates[11].localDateValue()).toBe(1389243600000);
8688
};
8789

8890
spyOn($rootScope, 'beforeRender').and.callThrough();
@@ -158,7 +160,7 @@ describe('beforeRender', function () {
158160
selectedElement.trigger('click');
159161

160162
expect($rootScope.beforeRender).toHaveBeenCalled();
161-
expect($rootScope.beforeRender.calls.argsFor(0)[0].dateValue).toEqual(631152000000); // 1990-01-01
163+
expect($rootScope.beforeRender.calls.argsFor(0)[0].utcDateValue).toEqual(631152000000); // 1990-01-01
162164
});
163165

164166

@@ -178,7 +180,7 @@ describe('beforeRender', function () {
178180
selectedElement.trigger('click');
179181

180182
expect($rootScope.beforeRender).toHaveBeenCalled();
181-
expect($rootScope.beforeRender.calls.argsFor(0)[0].dateValue).toEqual(1420070400000); // 2015-01-01
183+
expect($rootScope.beforeRender.calls.argsFor(0)[0].utcDateValue).toEqual(1420070400000); // 2015-01-01
182184
});
183185

184186

@@ -199,7 +201,7 @@ describe('beforeRender', function () {
199201

200202
expect($rootScope.beforeRender).toHaveBeenCalled();
201203

202-
expect($rootScope.beforeRender.calls.argsFor(0)[0].dateValue).toEqual(1388534400000); // 2014-01-01 - the start of the 'month' view.
204+
expect($rootScope.beforeRender.calls.argsFor(0)[0].utcDateValue).toEqual(1388534400000); // 2014-01-01 - the start of the 'month' view.
203205

204206

205207
var selectedElement = jQuery(jQuery('.day', element)[2]);
@@ -227,7 +229,7 @@ describe('beforeRender', function () {
227229
$rootScope.$digest();
228230

229231
expect($scope.beforeRender).toHaveBeenCalled();
230-
expect($scope.beforeRender.calls.argsFor(0)[0].dateValue).toEqual(1412121600000); // 2014-10-01 12:00 the start of the 'day' view
232+
expect($scope.beforeRender.calls.argsFor(0)[0].utcDateValue).toEqual(1412121600000); // 2014-10-01 12:00 the start of the 'day' view
231233

232234
var selectedElement = jQuery(jQuery('.hour', element)[2]);
233235
selectedElement.trigger('click');
@@ -249,7 +251,7 @@ describe('beforeRender', function () {
249251
$rootScope.$digest();
250252

251253
expect($rootScope.beforeRender).toHaveBeenCalled();
252-
expect($rootScope.beforeRender.calls.argsFor(0)[0].dateValue).toEqual(1413590400000); // 2014-10-18 00:00 Z
254+
expect($rootScope.beforeRender.calls.argsFor(0)[0].utcDateValue).toEqual(1413590400000); // 2014-10-18 00:00 Z
253255

254256

255257
var selectedElement = jQuery(jQuery('.minute', element)[2]);

test/model/ngModelController.spec.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ describe('ngModelController', function () {
3333

3434
spyOn($rootScope, 'setTimeFunction');
3535

36-
var element = $compile('<form name="pickerform"><datetimepicker data-ng-model="data.dateValue" name="dateValue" data-on-set-time="setTimeFunction(newDate)" required data-datetimepicker-config="{ startView: \'day\', minView: \'day\' }" ></datetimepicker></form>')($rootScope);
36+
var formElement = $compile('<form name="pickerform"><datetimepicker data-ng-model="data.dateValue" name="dateValue" data-on-set-time="setTimeFunction(newDate)" required data-datetimepicker-config="{ startView: \'day\', minView: \'day\' }" ></datetimepicker></form>')($rootScope);
3737
$rootScope.$digest();
3838

39-
var picker = jQuery(jQuery('.datetimepicker', element));
39+
var picker = jQuery(jQuery('.datetimepicker', formElement));
4040

41-
expect(picker.hasClass('ng-pristine')).toBeTruthy(); // This will break in 1.3, not sure why.
41+
expect(formElement.hasClass('ng-pristine')).toBeTruthy();
42+
43+
// expect(picker.hasClass('ng-pristine')).toBeTruthy(); // This breaks in 1.3, not sure why.
4244
expect(picker.hasClass('ng-invalid')).toBeTruthy();
4345
expect(picker.hasClass('ng-dirty')).toBeFalsy();
4446
expect(picker.hasClass('ng-valid')).toBeFalsy();
@@ -53,6 +55,8 @@ describe('ngModelController', function () {
5355
expect(picker.hasClass('ng-dirty')).toBeTruthy();
5456
expect(picker.hasClass('ng-valid')).toBeTruthy();
5557

58+
expect(formElement.hasClass('ng-pristine')).toBeFalsy();
59+
expect(formElement.hasClass('ng-dirty')).toBeTruthy();
5660
});
5761
});
5862

test/view/de/day.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('de');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'day\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.day-view` class', function () {
30+
expect(jQuery('table', element).hasClass('day-view')).toBeTruthy();
31+
});
32+
});
33+
1534
describe('German day view with initial date of 2013-01-22', function () {
1635
'use strict';
1736
var $rootScope, element;

0 commit comments

Comments
 (0)