Skip to content

Commit

Permalink
fix: Calendar Heatmap day offset (#24989)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Aug 15, 2023
1 parent cacad56 commit 025e4d4
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down

0 comments on commit 025e4d4

Please sign in to comment.