Skip to content

Commit 30835ad

Browse files
committed
MAGETWO-53299: "Go Today" button is not working for dates range component
1 parent 859a118 commit 30835ad

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

lib/web/mage/calendar.js

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,34 @@
2626

2727
$.datepicker.markerClassName = '_has-datepicker';
2828

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-
5429
/**
5530
* Extend JQuery date picker prototype with store local time methods
5631
*/
5732
$.extend(datepickerPrototype, {
5833

5934
/**
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
6138
* @returns {Date}
62-
* @private
6339
*/
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);
6657
},
6758

6859
/**
@@ -406,7 +397,7 @@
406397
* @return {Object} date
407398
*/
408399
getTimezoneDate: function () {
409-
return getTimezoneDate();
400+
return datepickerPrototype._getTimezoneDate.call(this, this.options);
410401
}
411402
});
412403

@@ -559,7 +550,6 @@
559550
* @param {Object} el
560551
*/
561552
$.datepicker._gotoToday = function (el) {
562-
563553
//Set date/time according to timezone offset
564554
$(el).datepicker('setTimezoneDate')
565555
// To ensure that user can re-select date field without clicking outside it first.

0 commit comments

Comments
 (0)