projects
/
dygraphs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
41deeaf
)
wrap Date.parse() defensively (mootools and joomla override it with something incompa...
author
Dan Vanderkam
<dan@dygraphs.com>
Mon, 4 Apr 2011 03:11:48 +0000
(23:11 -0400)
committer
Dan Vanderkam
<dan@dygraphs.com>
Mon, 4 Apr 2011 03:11:48 +0000
(23:11 -0400)
dygraph.js
patch
|
blob
|
blame
|
history
diff --git
a/dygraph.js
b/dygraph.js
index
1b8d8c7
..
4432498
100644
(file)
--- a/
dygraph.js
+++ b/
dygraph.js
@@
-2087,7
+2087,7
@@
Dygraph.prototype.GetXAxis = function(start_time, end_time, granularity) {
if (i % year_mod != 0) continue;
for (var j = 0; j < months.length; j++) {
var date_str = i + "/" + zeropad(1 + months[j]) + "/01";
if (i % year_mod != 0) continue;
for (var j = 0; j < months.length; j++) {
var date_str = i + "/" + zeropad(1 + months[j]) + "/01";
- var t = D
ate.parse
(date_str);
+ var t = D
ygraph.dateStrToMillis
(date_str);
if (t < start_time || t > end_time) continue;
ticks.push({ v:t, label: formatter(new Date(t), granularity) });
}
if (t < start_time || t > end_time) continue;
ticks.push({ v:t, label: formatter(new Date(t), granularity) });
}
@@
-2972,16
+2972,16
@@
Dygraph.dateParser = function(dateStr, self) {
while (dateStrSlashed.search("-") != -1) {
dateStrSlashed = dateStrSlashed.replace("-", "/");
}
while (dateStrSlashed.search("-") != -1) {
dateStrSlashed = dateStrSlashed.replace("-", "/");
}
- d = D
ate.parse
(dateStrSlashed);
+ d = D
ygraph.dateStrToMillis
(dateStrSlashed);
} else if (dateStr.length == 8) { // e.g. '20090712'
// TODO(danvk): remove support for this format. It's confusing.
dateStrSlashed = dateStr.substr(0,4) + "/" + dateStr.substr(4,2)
+ "/" + dateStr.substr(6,2);
} else if (dateStr.length == 8) { // e.g. '20090712'
// TODO(danvk): remove support for this format. It's confusing.
dateStrSlashed = dateStr.substr(0,4) + "/" + dateStr.substr(4,2)
+ "/" + dateStr.substr(6,2);
- d = D
ate.parse
(dateStrSlashed);
+ d = D
ygraph.dateStrToMillis
(dateStrSlashed);
} else {
// Any format that Date.parse will accept, e.g. "2009/07/12" or
// "2009/07/12 12:34:56"
} else {
// Any format that Date.parse will accept, e.g. "2009/07/12" or
// "2009/07/12 12:34:56"
- d = D
ate.parse
(dateStr);
+ d = D
ygraph.dateStrToMillis
(dateStr);
}
if (!d || isNaN(d)) {
}
if (!d || isNaN(d)) {
@@
-3368,6
+3368,13
@@
Dygraph.prototype.parseDataTable_ = function(data) {
}
}
}
}
+// This is identical to JavaScript's built-in Date.parse() method, except that
+// it doesn't get replaced with an incompatible method by aggressive JS
+// libraries like MooTools or Joomla.
+Dygraph.dateStrToMillis = function(str) {
+ return new Date(str).getTime();
+};
+
// These functions are all based on MochiKit.
Dygraph.update = function (self, o) {
if (typeof(o) != 'undefined' && o !== null) {
// These functions are all based on MochiKit.
Dygraph.update = function (self, o) {
if (typeof(o) != 'undefined' && o !== null) {