Commit 0e42a9a
committed
Fix d3.time.day for Firefox in Europe/London.
The UK was on permanent BST from February 1968 until October 1971. This
is handled differently by Chrome and Firefox. Chrome appears to apply
"current" DST rules, hence new Date(0) is 00:00. Firefox thinks it is
in BST, and thus new Date(0) is 01:00, and in fact there appears to be
no such thing as a local time of 00:00 on Jan 1st, 1970.
This difference in interpretation caused d3.time.day.floor to return
01:00 instead of 00:00 due to internally using new Date(1970, 0), which
is equivalent to new Date(0).
This led to the discovery of other timezone-related bugs, where a DST
change caused a day to start at 01:00 instead of 00:00. Up until now,
we had been assuming that every day had a midnight, but this is not the
case, e.g., Fri Mar 28 2014 in Asia/Amman.
This assumption was present in d3.time.scale, where a date with a
non-zero hour was being formatted as "%I %p", even if it was a date
returned by d3.time.day.floor.
To fix the Firefox issue with the time being 01:00 at the epoch, we use
date.setHours(0, 0, 0, 0) to ensure a midnight is returned if it exists.
We then check to see if the resulting date is on a day boundary, by
subtracting a millisecond and comparing the year, month and day fields.
If not, we perform a binary search to find the true boundary, which
fixes the aforementioned example Asia/Amman problem.
Lastly, d3.time.scale was adjusted to check for boundaries using the
millisecond decrement technique, rather than checking for non-zero
fields.1 parent 41bfffe commit 0e42a9a
5 files changed
Lines changed: 95 additions & 63 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8289 | 8289 | | |
8290 | 8290 | | |
8291 | 8291 | | |
8292 | | - | |
8293 | | - | |
| 8292 | + | |
| 8293 | + | |
| 8294 | + | |
| 8295 | + | |
| 8296 | + | |
| 8297 | + | |
| 8298 | + | |
| 8299 | + | |
8294 | 8300 | | |
8295 | 8301 | | |
8296 | 8302 | | |
| |||
8303 | 8309 | | |
8304 | 8310 | | |
8305 | 8311 | | |
| 8312 | + | |
| 8313 | + | |
| 8314 | + | |
8306 | 8315 | | |
8307 | 8316 | | |
8308 | 8317 | | |
| |||
8689 | 8698 | | |
8690 | 8699 | | |
8691 | 8700 | | |
8692 | | - | |
| 8701 | + | |
8693 | 8702 | | |
8694 | 8703 | | |
8695 | 8704 | | |
8696 | 8705 | | |
8697 | 8706 | | |
8698 | 8707 | | |
8699 | 8708 | | |
| 8709 | + | |
8700 | 8710 | | |
8701 | 8711 | | |
8702 | | - | |
| 8712 | + | |
| 8713 | + | |
8703 | 8714 | | |
8704 | 8715 | | |
8705 | 8716 | | |
| |||
8714 | 8725 | | |
8715 | 8726 | | |
8716 | 8727 | | |
8717 | | - | |
8718 | | - | |
| 8728 | + | |
| 8729 | + | |
| 8730 | + | |
8719 | 8731 | | |
8720 | 8732 | | |
8721 | 8733 | | |
| |||
8730 | 8742 | | |
8731 | 8743 | | |
8732 | 8744 | | |
8733 | | - | |
8734 | | - | |
8735 | | - | |
8736 | | - | |
8737 | | - | |
8738 | | - | |
8739 | | - | |
8740 | | - | |
8741 | | - | |
8742 | | - | |
8743 | | - | |
8744 | | - | |
8745 | | - | |
8746 | | - | |
8747 | | - | |
| 8745 | + | |
| 8746 | + | |
| 8747 | + | |
| 8748 | + | |
| 8749 | + | |
| 8750 | + | |
| 8751 | + | |
| 8752 | + | |
| 8753 | + | |
| 8754 | + | |
| 8755 | + | |
| 8756 | + | |
| 8757 | + | |
| 8758 | + | |
| 8759 | + | |
| 8760 | + | |
8748 | 8761 | | |
8749 | 8762 | | |
8750 | 8763 | | |
| |||
8755 | 8768 | | |
8756 | 8769 | | |
8757 | 8770 | | |
8758 | | - | |
8759 | | - | |
8760 | | - | |
8761 | | - | |
8762 | | - | |
8763 | | - | |
8764 | | - | |
8765 | | - | |
8766 | | - | |
8767 | | - | |
8768 | | - | |
8769 | | - | |
8770 | | - | |
8771 | | - | |
8772 | | - | |
| 8771 | + | |
| 8772 | + | |
| 8773 | + | |
| 8774 | + | |
| 8775 | + | |
| 8776 | + | |
| 8777 | + | |
| 8778 | + | |
| 8779 | + | |
| 8780 | + | |
| 8781 | + | |
| 8782 | + | |
| 8783 | + | |
| 8784 | + | |
| 8785 | + | |
8773 | 8786 | | |
8774 | 8787 | | |
8775 | 8788 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
8 | 17 | | |
9 | 18 | | |
10 | 19 | | |
| |||
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | | - | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
70 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| 134 | + | |
| 135 | + | |
130 | 136 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
| |||
0 commit comments