Added NaN check to date.parse