fix: Calendar Heatmap day offset (#24989)
This commit is contained in:
parent
cacad56172
commit
025e4d4772
|
|
@ -296,8 +296,21 @@ var CalHeatMap = function () {
|
|||
// Used mainly to convert the datas if they're not formatted like expected
|
||||
// Takes the fetched "data" object as argument, must return a json object
|
||||
// formatted like {timestamp:count, timestamp2:count2},
|
||||
afterLoadData: function (data) {
|
||||
return data;
|
||||
afterLoadData: function (timestamps) {
|
||||
// See https://github.com/wa0x6e/cal-heatmap/issues/126#issuecomment-373301803
|
||||
const stdTimezoneOffset = date => {
|
||||
const jan = new Date(date.getFullYear(), 0, 1);
|
||||
const jul = new Date(date.getFullYear(), 6, 1);
|
||||
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
|
||||
};
|
||||
const offset = stdTimezoneOffset(new Date()) * 60;
|
||||
let results = {};
|
||||
for (let timestamp in timestamps) {
|
||||
const value = timestamps[timestamp];
|
||||
timestamp = parseInt(timestamp, 10);
|
||||
results[timestamp + offset] = value;
|
||||
}
|
||||
return results;
|
||||
},
|
||||
|
||||
// Callback triggered after calling and completing update().
|
||||
|
|
|
|||
Loading…
Reference in New Issue