Fix for invalid date format issue in Firefox

This commit is contained in:
Duncan Sommerville 2015-04-29 15:23:29 -04:00
parent 950dd22697
commit e73a6df796
1 changed files with 6 additions and 0 deletions

View File

@ -260,6 +260,12 @@
$("p.now_playing").html(artist + "<span>" + track + "</span>");
var current_track_end_time = new Date(data.current.ends);
if (current_track_end_time == "Invalid Date" || isNaN(current_track_end_time)) {
// If the conversion didn't work (since the String is not in ISO format)
// then change it to be ISO-compliant. This is somewhat hacky and may break
// if the date string format in live-info changes!
current_track_end_time = new Date((data.current.ends).replace(" ", "T"));
}
var current_time = new Date();
//convert current_time to UTC to match the timezone of time_to_next_track_starts
current_time = new Date(current_time.getTime() + current_time.getTimezoneOffset() * 60 * 1000);