|
2 | 2 | /*jslint vars:true */
|
3 | 3 |
|
4 | 4 | /**
|
5 |
| - * @license angular-bootstrap-datetimepicker version: 0.3.8 |
| 5 | + * @license angular-bootstrap-datetimepicker version: 0.3.10 |
6 | 6 | * (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
|
7 | 7 | * License: MIT
|
8 | 8 | */
|
|
16 | 16 | (function (factory) {
|
17 | 17 | 'use strict';
|
18 | 18 | /* istanbul ignore if */
|
19 |
| - if (typeof define === 'function' && /* istanbul ignore next */ define.amd) { |
| 19 | + if (typeof define === 'function' && /* istanbul ignore next */ define.amd) { |
20 | 20 | define(['angular', 'moment'], factory); // AMD
|
21 | 21 | } else {
|
22 | 22 | factory(window.angular, window.moment); // Browser global
|
|
34 | 34 |
|
35 | 35 | function DateObject() {
|
36 | 36 |
|
37 |
| - this.dateValue = new Date().getTime(); |
| 37 | + var tempDate = new Date(); |
| 38 | + var localOffset = tempDate.getTimezoneOffset() * 60000; |
| 39 | + this.utcDateValue = tempDate.getTime(); |
38 | 40 | this.selectable = true;
|
39 | 41 |
|
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']; |
41 | 47 |
|
42 | 48 | for (var prop in arguments[0]) {
|
43 | 49 | /* istanbul ignore else */
|
|
163 | 169 | var result = {
|
164 | 170 | 'currentView': 'year',
|
165 | 171 | '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()}), |
169 | 175 | 'dates': []
|
170 | 176 | };
|
171 | 177 |
|
172 | 178 | for (var i = 0; i < 12; i += 1) {
|
173 | 179 | var yearMoment = moment.utc(startDate).add(i, 'years');
|
174 | 180 | var dateValue = {
|
175 |
| - 'dateValue': yearMoment.valueOf(), |
| 181 | + 'utcDateValue': yearMoment.valueOf(), |
176 | 182 | 'display': yearMoment.format('YYYY'),
|
177 | 183 | 'past': yearMoment.year() < startDecade,
|
178 | 184 | 'future': yearMoment.year() > startDecade + 9,
|
|
196 | 202 | 'currentView': 'month',
|
197 | 203 | 'nextView': configuration.minView === 'month' ? 'setTime' : 'day',
|
198 | 204 | 'previousViewDate': new DateObject({
|
199 |
| - dateValue: previousViewDate.valueOf(), |
| 205 | + utcDateValue: previousViewDate.valueOf(), |
200 | 206 | display: startDate.format('YYYY')
|
201 | 207 | }),
|
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()}), |
204 | 210 | 'dates': []
|
205 | 211 | };
|
206 | 212 |
|
207 | 213 | for (var i = 0; i < 12; i += 1) {
|
208 | 214 | var monthMoment = moment.utc(startDate).add(i, 'months');
|
209 | 215 | var dateValue = {
|
210 |
| - 'dateValue': monthMoment.valueOf(), |
| 216 | + 'utcDateValue': monthMoment.valueOf(), |
211 | 217 | 'display': monthMoment.format('MMM'),
|
212 | 218 | 'active': monthMoment.format('YYYY-MMM') === activeDate
|
213 | 219 | };
|
|
234 | 240 | 'currentView': 'day',
|
235 | 241 | 'nextView': configuration.minView === 'day' ? 'setTime' : 'hour',
|
236 | 242 | 'previousViewDate': new DateObject({
|
237 |
| - dateValue: previousViewDate.valueOf(), |
| 243 | + utcDateValue: previousViewDate.valueOf(), |
238 | 244 | display: startOfMonth.format('YYYY-MMM')
|
239 | 245 | }),
|
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()}), |
242 | 248 | 'dayNames': [],
|
243 | 249 | 'weeks': []
|
244 | 250 | };
|
|
253 | 259 | for (var j = 0; j < 7; j += 1) {
|
254 | 260 | var monthMoment = moment.utc(startDate).add((i * 7) + j, 'days');
|
255 | 261 | var dateValue = {
|
256 |
| - 'dateValue': monthMoment.valueOf(), |
| 262 | + 'utcDateValue': monthMoment.valueOf(), |
257 | 263 | 'display': monthMoment.format('D'),
|
258 | 264 | 'active': monthMoment.format('YYYY-MMM-DD') === activeDate,
|
259 | 265 | 'past': monthMoment.isBefore(startOfMonth),
|
|
278 | 284 | 'currentView': 'hour',
|
279 | 285 | 'nextView': configuration.minView === 'hour' ? 'setTime' : 'minute',
|
280 | 286 | 'previousViewDate': new DateObject({
|
281 |
| - dateValue: previousViewDate.valueOf(), |
| 287 | + utcDateValue: previousViewDate.valueOf(), |
282 | 288 | display: selectedDate.format('ll')
|
283 | 289 | }),
|
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()}), |
286 | 292 | 'dates': []
|
287 | 293 | };
|
288 | 294 |
|
289 | 295 | for (var i = 0; i < 24; i += 1) {
|
290 | 296 | var hourMoment = moment.utc(selectedDate).add(i, 'hours');
|
291 | 297 | var dateValue = {
|
292 |
| - 'dateValue': hourMoment.valueOf(), |
| 298 | + 'utcDateValue': hourMoment.valueOf(), |
293 | 299 | 'display': hourMoment.format('LT'),
|
294 | 300 | 'active': hourMoment.format('YYYY-MM-DD H') === activeFormat
|
295 | 301 | };
|
|
310 | 316 | 'currentView': 'minute',
|
311 | 317 | 'nextView': 'setTime',
|
312 | 318 | 'previousViewDate': new DateObject({
|
313 |
| - dateValue: previousViewDate.valueOf(), |
| 319 | + utcDateValue: previousViewDate.valueOf(), |
314 | 320 | display: selectedDate.format('lll')
|
315 | 321 | }),
|
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()}), |
318 | 324 | 'dates': []
|
319 | 325 | };
|
320 | 326 |
|
|
323 | 329 | for (var i = 0; i < limit; i += 1) {
|
324 | 330 | var hourMoment = moment.utc(selectedDate).add(i * configuration.minuteStep, 'minute');
|
325 | 331 | var dateValue = {
|
326 |
| - 'dateValue': hourMoment.valueOf(), |
| 332 | + 'utcDateValue': hourMoment.valueOf(), |
327 | 333 | 'display': hourMoment.format('LT'),
|
328 | 334 | 'active': hourMoment.format('YYYY-MM-DD H:mm') === activeFormat
|
329 | 335 | };
|
|
362 | 368 | event.preventDefault();
|
363 | 369 | }
|
364 | 370 |
|
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); |
367 | 373 |
|
368 | 374 | var weekDates = [];
|
369 | 375 | if (result.weeks) {
|
|
389 | 395 | };
|
390 | 396 |
|
391 | 397 | 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)})); |
393 | 399 | };
|
394 | 400 | }
|
395 | 401 | };
|
|
0 commit comments