|
26 | 26 |
|
27 | 27 | $.datepicker.markerClassName = '_has-datepicker';
|
28 | 28 |
|
29 |
| - /** |
30 |
| - * Get date/time according to store settings. |
31 |
| - * We use serverTimezoneOffset (in seconds) instead of serverTimezoneSeconds |
32 |
| - * in order to have ability to know actual store time even if page hadn't been reloaded |
33 |
| - * @returns {Date} |
34 |
| - */ |
35 |
| - function getTimezoneDate() { |
36 |
| - |
37 |
| - // local time in ms |
38 |
| - var ms = Date.now(), |
39 |
| - options = $.calendarConfig ? $.calendarConfig : {}; |
40 |
| - |
41 |
| - // Adjust milliseconds according to store timezone offset, |
42 |
| - // mind the GMT zero offset |
43 |
| - if (typeof options.serverTimezoneOffset !== 'undefined') { |
44 |
| - // Make UTC time and add store timezone offset in seconds |
45 |
| - ms += new Date().getTimezoneOffset() * 60 * 1000 + options.serverTimezoneOffset * 1000; |
46 |
| - } else if (typeof options.serverTimezoneSeconds !== 'undefined') { |
47 |
| - //Set milliseconds according to client local timezone offset |
48 |
| - ms = (options.serverTimezoneSeconds + new Date().getTimezoneOffset() * 60) * 1000; |
49 |
| - } |
50 |
| - |
51 |
| - return new Date(ms); |
52 |
| - } |
53 |
| - |
54 | 29 | /**
|
55 | 30 | * Extend JQuery date picker prototype with store local time methods
|
56 | 31 | */
|
57 | 32 | $.extend(datepickerPrototype, {
|
58 | 33 |
|
59 | 34 | /**
|
60 |
| - * Get date/time according to store settings |
| 35 | + * Get date/time according to store settings. |
| 36 | + * We use serverTimezoneOffset (in seconds) instead of serverTimezoneSeconds |
| 37 | + * in order to have ability to know actual store time even if page hadn't been reloaded |
61 | 38 | * @returns {Date}
|
62 |
| - * @private |
63 | 39 | */
|
64 |
| - _getTimezoneDate: function () { |
65 |
| - return getTimezoneDate(); |
| 40 | + _getTimezoneDate: function (options) { |
| 41 | + // local time in ms |
| 42 | + var ms = Date.now(); |
| 43 | + |
| 44 | + options = options || $.calendarConfig ? $.calendarConfig : {}; |
| 45 | + |
| 46 | + // Adjust milliseconds according to store timezone offset, |
| 47 | + // mind the GMT zero offset |
| 48 | + if (typeof options.serverTimezoneOffset !== 'undefined') { |
| 49 | + // Make UTC time and add store timezone offset in seconds |
| 50 | + ms += new Date().getTimezoneOffset() * 60 * 1000 + options.serverTimezoneOffset * 1000; |
| 51 | + } else if (typeof options.serverTimezoneSeconds !== 'undefined') { |
| 52 | + //Set milliseconds according to client local timezone offset |
| 53 | + ms = (options.serverTimezoneSeconds + new Date().getTimezoneOffset() * 60) * 1000; |
| 54 | + } |
| 55 | + |
| 56 | + return new Date(ms); |
66 | 57 | },
|
67 | 58 |
|
68 | 59 | /**
|
|
406 | 397 | * @return {Object} date
|
407 | 398 | */
|
408 | 399 | getTimezoneDate: function () {
|
409 |
| - return getTimezoneDate(); |
| 400 | + return datepickerPrototype._getTimezoneDate.call(this, this.options); |
410 | 401 | }
|
411 | 402 | });
|
412 | 403 |
|
|
559 | 550 | * @param {Object} el
|
560 | 551 | */
|
561 | 552 | $.datepicker._gotoToday = function (el) {
|
562 |
| - |
563 | 553 | //Set date/time according to timezone offset
|
564 | 554 | $(el).datepicker('setTimezoneDate')
|
565 | 555 | // To ensure that user can re-select date field without clicking outside it first.
|
|
0 commit comments