|
24 | 24 | var calendarBasePrototype,
|
25 | 25 | datepickerPrototype = $.datepicker.constructor.prototype;
|
26 | 26 |
|
| 27 | + $.datepicker.markerClassName = '_has-datepicker'; |
| 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 | + |
27 | 54 | /**
|
28 | 55 | * Extend JQuery date picker prototype with store local time methods
|
29 | 56 | */
|
30 | 57 | $.extend(datepickerPrototype, {
|
31 | 58 |
|
32 | 59 | /**
|
33 |
| - * Get date/time according to store settings. |
34 |
| - * We use serverTimezoneOffset (in seconds) instead of serverTimezoneSeconds |
35 |
| - * in order to have ability to know actual store time even if page hadn't been reloaded |
| 60 | + * Get date/time according to store settings |
36 | 61 | * @returns {Date}
|
| 62 | + * @private |
37 | 63 | */
|
38 | 64 | _getTimezoneDate: function () {
|
39 |
| - // local time in ms |
40 |
| - var ms = Date.now(), |
41 |
| - options = $.calendarConfig ? $.calendarConfig : {}; |
42 |
| - |
43 |
| - // Adjust milliseconds according to store timezone offset, |
44 |
| - // mind the GMT zero offset |
45 |
| - if (typeof options.serverTimezoneOffset !== 'undefined') { |
46 |
| - // Make UTC time and add store timezone offset in seconds |
47 |
| - ms += new Date().getTimezoneOffset() * 60 * 1000 + options.serverTimezoneOffset * 1000; |
48 |
| - } else if (typeof options.serverTimezoneSeconds !== 'undefined') { |
49 |
| - //Set milliseconds according to client local timezone offset |
50 |
| - ms = (options.serverTimezoneSeconds + new Date().getTimezoneOffset() * 60) * 1000; |
51 |
| - } |
52 |
| - |
53 |
| - return new Date(ms); |
| 65 | + return getTimezoneDate(); |
54 | 66 | },
|
55 | 67 |
|
56 | 68 | /**
|
|
62 | 74 | }
|
63 | 75 | });
|
64 | 76 |
|
65 |
| - $.datepicker.markerClassName = '_has-datepicker'; |
66 |
| - |
67 | 77 | /**
|
68 | 78 | * Widget calendar
|
69 | 79 | */
|
|
396 | 406 | * @return {Object} date
|
397 | 407 | */
|
398 | 408 | getTimezoneDate: function () {
|
399 |
| - return datepickerPrototype._getTimezoneDate.call(this); |
| 409 | + return getTimezoneDate(); |
400 | 410 | }
|
401 | 411 | });
|
402 | 412 |
|
|
0 commit comments