sparkartgroup-archive / sparkart.js

Easily interact with Sparkart's APIs via Javascript.
1 stars 0 forks source link

Error in date formatting preventing template rendering in Safari/Firefox #50

Closed pushred closed 11 years ago

pushred commented 11 years ago

There's some sort of issue in the date formatting code that's only happening in Safari and Firefox. It doesn't happen in Chrome or IE 9 & 10. The error returned is:

TypeError: DAYS[day_of_week] is undefined
abbr: DAYS[day_of_week].substr( 0, 3 )

To reproduce visit http://ufcfightclub.com and select the home page Pre-sales tab. This is a high priority because it's blocking rendering of ticketing links.

Fauntleroy commented 11 years ago

The problem is here:

var day_of_week = new Date( month +'-'+ day +'-'+ year ).getDay();

Looks like some browsers don't parse strings passed to Date properly. Luckily, there is a standard method which I was far too silly to utilize the first time around:

new Date( year, month, day )