Skip to content

Commit

Permalink
Offsets user displayed time to server timezone(EST) for the heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
terakilobyte committed Nov 7, 2015
1 parent c30f7f0 commit d6cea74
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion server/views/account/show.jade
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,29 @@ block content
#cal-heatmap.d3-centered
script.
$(document).ready(function () {
var estUTCOffset = -5;
// moment returns the utc offset in minutes
var userUTCOffset = moment().utcOffset() / 60;
var secondsToOffset =
(estUTCOffset - userUTCOffset) * 3600;
var cal = new CalHeatMap();
var calendar = !{JSON.stringify(calender)};
var offsetCalendar = {};
for (var prop in calendar) {
if (calendar.hasOwnProperty(prop)) {
var offsetProp = +prop + secondsToOffset;
offsetCalendar[offsetProp] =
calendar[prop];
}
}
console.log(calendar);
console.log(offsetCalendar);
cal.init({
itemSelector: "#cal-heatmap",
domain: "month",
subDomain: "x_day",
domainGutter: 10,
data: calendar,
data: offsetCalendar,
cellSize: 15,
align: 'center',
cellRadius: 3,
Expand Down

0 comments on commit d6cea74

Please sign in to comment.