From cfe0d7aa0c50e7dbd32166a40edfd34c327f809e Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 7 Sep 2012 12:05:48 -0400 Subject: [PATCH] Unrelated refactorings of Show.php. Added TODO for more later work. --- airtime_mvc/application/models/Show.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 0fa4fb3cc..dc88e151d 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -436,13 +436,21 @@ SQL; $rebroadcastsLocal = array(); //get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time. + /*TODO: refactor the following code to get rid of the $i temporary + variable. -- RG*/ $i = 0; - foreach ($rebroadcasts as $show) { - $startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC")); - $startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); - $rebroadcastsLocal[$i]["start_date"] = $startDateTime->format("Y-m-d"); - $rebroadcastsLocal[$i]["start_time"] = $startDateTime->format("H:i"); + $utc = new DateTimeZone("UTC"); + $dtz = new DateTimeZone( date_default_timezone_get() ); + + foreach ($rebroadcasts as $show) { + $startDateTime = new DateTime($show["starts"], $utc); + $startDateTime->setTimezone($dtz); + + $rebroadcastsLocal[$i]["start_date"] = + $startDateTime->format("Y-m-d"); + $rebroadcastsLocal[$i]["start_time"] = + $startDateTime->format("H:i"); $i = $i + 1; }