Fixed potential limitation in pull request #27

Not a bug but possibly a limitation for certain date formats.
master
John Kiernander 2013-11-22 22:28:47 +00:00
parent 5cb73e7fd4
commit 61119bbe17
1 changed files with 11 additions and 7 deletions

View File

@ -4,13 +4,17 @@
this._parseDate = function (inDate) {
// A javascript date object
var outDate;
if (!isNaN(inDate)) {
// If inDate is a number, assume it's epoch time
outDate = new Date(inDate);
} else if (this.dateParseFormat === null || this.dateParseFormat === undefined) {
// If nothing has been explicity defined you are in the hands of the browser gods
// may they smile upon you...
outDate = Date.parse(inDate);
if (this.dateParseFormat === null || this.dateParseFormat === undefined) {
// Moved this into the condition so that using epoch time requires no data format to be set.
// For example 20131122 might be parsed as %Y%m%d not treated as epoch time.
if (!isNaN(inDate)) {
// If inDate is a number, assume it's epoch time
outDate = new Date(inDate);
} else {
// If nothing has been explicity defined you are in the hands of the browser gods
// may they smile upon you...
outDate = Date.parse(inDate);
}
} else {
outDate = d3.time.format(this.dateParseFormat).parse(inDate);
}