Skip to content

Problem parsing date on parseDate function (when date is a string) #1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lbortoli opened this issue Mar 9, 2015 · 1 comment
Closed

Comments

@lbortoli
Copy link
Contributor

lbortoli commented Mar 9, 2015

I think I noticed the error:

c3_chart_internal_fn.parseDate = function (date) {
var $$ = this, parsedDate;
if (date instanceof Date) {
parsedDate = date;
} else if (typeof date === 'number' && !isNaN(date)) {// fixed wrong validation
parsedDate = new Date(+date);
} else {
parsedDate = . d a t a T i m e F o r m a t ( .config.data_xFormat).parse(date);
}
if (!parsedDate || isNaN(+parsedDate)) {
window.console.error("Failed to parse x '" + date + "' to Date object");
}
return parsedDate;
};

The issue was on the validation
if (typeof date === 'number' || !isNaN(date))

it should be
if (typeof date === 'number' && !isNaN(date))

masayuki0812 added a commit that referenced this issue Aug 10, 2015
@michaelrodov
Copy link

fix commited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants