Skip to content

Commit

Permalink
corrected fix for the calendar example: do NOT mix UTC and Local Time…
Browse files Browse the repository at this point in the history
…Zone date operations in calculations which depend on identifying day/month transitions - default JavaScript Date object works with 'local timezone'. Fix tested in AZ/USA and Amsterdam/EUR timezones.
  • Loading branch information
GerHobbelt committed Dec 27, 2011
1 parent da76aa2 commit 7d298c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/calendar/dji.js
Expand Up @@ -48,15 +48,15 @@ d3.csv("dji.csv", function(csv) {
.map(csv);

rect
.attr("class", function(d) {
.attr("class", function(d) {
var dv = data[format(d)];
return "day q" + (dv ? color(dv) : "X") + "-9"; })
.append("title")
.text(function(d) { return (d = format(d)) + (d in data ? ": " + percent(data[d]) : ""); });
});

function monthPath(t0) {
var t1 = new Date(t0.getUTCFullYear(), t0.getUTCMonth() + 2, 0),
var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
d0 = +day(t0), w0 = +week(t0),
d1 = +day(t1), w1 = +week(t1);
return "M" + (w0 + 1) * z + "," + d0 * z
Expand Down
4 changes: 2 additions & 2 deletions examples/calendar/vix.js
Expand Up @@ -48,15 +48,15 @@ d3.csv("vix.csv", function(csv) {
color.domain(d3.values(data));

rect
.attr("class", function(d) {
.attr("class", function(d) {
var dv = data[format(d)];
return "day q" + (dv ? color(dv) : "X") + "-9"; })
.append("title")
.text(function(d) { return (d = format(d)) + (d in data ? ": " + data[d] : ""); });
});

function monthPath(t0) {
var t1 = new Date(t0.getUTCFullYear(), t0.getUTCMonth() + 2, 0),
var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
d0 = +day(t0), w0 = +week(t0),
d1 = +day(t1), w1 = +week(t1);
return "M" + (w0 + 1) * z + "," + d0 * z
Expand Down

0 comments on commit 7d298c0

Please sign in to comment.