From a5a91c25e01a5dcceabddaaaa473587159aae7a0 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 6 Jul 2015 12:53:15 -0400 Subject: [PATCH] SAAS-929: Shows don't show up on schedule widget on Firefox --- airtime_mvc/application/common/WidgetHelper.php | 10 ++++++++++ .../views/scripts/embed/weekly-program.phtml | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/common/WidgetHelper.php b/airtime_mvc/application/common/WidgetHelper.php index d22727ad9..8be23e200 100644 --- a/airtime_mvc/application/common/WidgetHelper.php +++ b/airtime_mvc/application/common/WidgetHelper.php @@ -127,6 +127,16 @@ class WidgetHelper "ALL", $showQueryDateRangeEnd->format("Y-m-d H:i:s")); + // Convert each start and end time string to DateTime objects + // so we can get a real timestamp. The timestamps will be used + // to convert into javascript Date objects. + foreach($shows as &$show) { + $dtStarts = new DateTime($show["starts"], new DateTimeZone("UTC")); + $show["starts_timestamp"] = $dtStarts->getTimestamp(); + + $dtEnds = new DateTime($show["ends"], new DateTimeZone("UTC")); + $show["ends_timestamp"] = $dtEnds->getTimestamp(); + } $result["shows"] = $shows; // XSS exploit prevention diff --git a/airtime_mvc/application/views/scripts/embed/weekly-program.phtml b/airtime_mvc/application/views/scripts/embed/weekly-program.phtml index 872afc849..911cd4b87 100644 --- a/airtime_mvc/application/views/scripts/embed/weekly-program.phtml +++ b/airtime_mvc/application/views/scripts/embed/weekly-program.phtml @@ -40,8 +40,10 @@ // First we have to create a Date object out of the show time in UTC. // Then we can format the string in the client's local timezone. - var start_date = new Date(value.starts + " UTC"); - var end_date = new Date(value.ends + " UTC"); + // NOTE: we have to multiply the timestamp by 1000 because in PHP + // the timestamps are in seconds and are in milliseconds in javascript. + var start_date = new Date(value.starts_timestamp*1000); + var end_date = new Date(value.ends_timestamp*1000); // This variable is used to identify which schedule_data object (which day of the week) // we should assign the show to.