X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=30ea7a8a25be5f7b4b0a1198edd0b58686676450;hb=d33de6cabb99ea446961ee20da465e5974ebbdf9;hp=623acf7eee157d2f9774d4bb424709b5c9047799;hpb=e5152598cf72fb46c396f79edebc68e9fb4fec73;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 623acf7..30ea7a8 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2112,7 +2112,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"; - var t = Date.parse(date_str); + var t = Dygraph.dateStrToMillis(date_str); if (t < start_time || t > end_time) continue; ticks.push({ v:t, label: formatter(new Date(t), granularity) }); } @@ -3035,16 +3035,16 @@ Dygraph.dateParser = function(dateStr, self) { while (dateStrSlashed.search("-") != -1) { dateStrSlashed = dateStrSlashed.replace("-", "/"); } - d = Date.parse(dateStrSlashed); + d = Dygraph.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); - d = Date.parse(dateStrSlashed); + d = Dygraph.dateStrToMillis(dateStrSlashed); } else { // Any format that Date.parse will accept, e.g. "2009/07/12" or // "2009/07/12 12:34:56" - d = Date.parse(dateStr); + d = Dygraph.dateStrToMillis(dateStr); } if (!d || isNaN(d)) { @@ -3431,6 +3431,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) {