From ec6a991090b32fedabf73679ff8e4f018ab2007e Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 5 Dec 2013 15:57:00 -0500 Subject: [PATCH] CC-5594 : Remove all date_default_timezone_get() missed a place to set show timezone, setting UTC timezone in CcSchedule, very important!! --- .../application/models/airtime/CcSchedule.php | 23 ++++++++++--------- .../application/services/ShowFormService.php | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/airtime_mvc/application/models/airtime/CcSchedule.php b/airtime_mvc/application/models/airtime/CcSchedule.php index db7fb19a7..9b6196f92 100644 --- a/airtime_mvc/application/models/airtime/CcSchedule.php +++ b/airtime_mvc/application/models/airtime/CcSchedule.php @@ -182,19 +182,20 @@ class CcSchedule extends BaseCcSchedule { */ public function setDbStarts($v) { + $utcTimeZone = new DateTimeZone('UTC'); + if ($v instanceof DateTime) { $dt = $v; + $dt->setTimezone($utcTimeZone); } else { // some string/numeric value passed; we normalize that so that we can // validate it. try { if (is_numeric($v)) { // if it's a unix timestamp - $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); - // We have to explicitly specify and then change the time zone because of a - // DateTime bug: http://bugs.php.net/bug.php?id=43003 - $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + $dt = new DateTime('@'.$v, $utcTimeZone); + } else { - $dt = new DateTime($v); + $dt = new DateTime($v, $utcTimeZone); } } catch (Exception $x) { throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); @@ -216,20 +217,20 @@ class CcSchedule extends BaseCcSchedule { */ public function setDbEnds($v) { - + $utcTimeZone = new DateTimeZone('UTC'); + if ($v instanceof DateTime) { $dt = $v; + $dt->setTimezone($utcTimeZone); } else { // some string/numeric value passed; we normalize that so that we can // validate it. try { if (is_numeric($v)) { // if it's a unix timestamp - $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); - // We have to explicitly specify and then change the time zone because of a - // DateTime bug: http://bugs.php.net/bug.php?id=43003 - $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + $dt = new DateTime('@'.$v, $utcTimeZone); + } else { - $dt = new DateTime($v); + $dt = new DateTime($v, $utcTimeZone); } } catch (Exception $x) { throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 96f5dc655..99361281e 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -187,7 +187,7 @@ class Application_Service_ShowFormService 'add_show_end_date_no_repeat' => $showEnd->format("Y-m-d"), 'add_show_end_time' => $showEnd->format("H:i"), 'add_show_duration' => $this->calculateDuration( - $showStart->format("Y-m-d H:i:s"), $showEnd->format("Y-m-d H:i:s")), + $showStart->format("Y-m-d H:i:s"), $showEnd->format("Y-m-d H:i:s"), $timezone), 'add_show_timezone' => $timezone, 'add_show_repeats' => 0));