From ed7447080306b3923353709105b43275edcbf57e Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 4 Dec 2013 17:54:28 -0500 Subject: [PATCH] CC-5594 : Remove all date_default_timezone_get() updating dashbaord information for timezone. --- airtime_mvc/application/common/DateHelper.php | 37 ------------------- airtime_mvc/application/models/Schedule.php | 18 +++++---- 2 files changed, 10 insertions(+), 45 deletions(-) diff --git a/airtime_mvc/application/common/DateHelper.php b/airtime_mvc/application/common/DateHelper.php index bbac8abc1..f12985804 100644 --- a/airtime_mvc/application/common/DateHelper.php +++ b/airtime_mvc/application/common/DateHelper.php @@ -111,43 +111,6 @@ class Application_Common_DateHelper return $this->_dateTime; } - /** - * Returns the offset in seconds, between local and UTC timezones. - * E.g., if local timezone is -4, this function - * returns -14400. - * - * @return type offset in int, between local and UTC timezones - */ - function getLocalTimeZoneOffset() { - $dateTime = new DateTime("@".$this->_dateTime, new DateTimeZone("UTC")); - $timezone = new DateTimeZone(date_default_timezone_get()); - return $timezone->getOffset($dateTime); - } - - /** - * Returns the offset hour in int, between local and UTC timezones. - * E.g., if local timezone is -4:30, this function - * returns -4. - * - * @return type offset hour in int, between local and UTC timezones - */ - function getLocalOffsetHour() { - $offset = $this->getLocalTimeZoneOffset(); - return (int)($offset / 3600); - } - - /** - * Returns the offset minute in int, between local and UTC timezones. - * E.g., if local timezone is -4:30, this function - * returns -30. - * - * @return type offset minute in int, between local and UTC timezones - */ - function getLocalOffsetMinute() { - $offset = $this->getLocalTimeZoneOffset(); - return (int)(($offset % 3600) / 60); - } - public static function TimeDiff($time1, $time2) { return strtotime($time2) - strtotime($time1); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 9e5dbaf60..6271f9a4d 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -72,25 +72,27 @@ SQL; return array(); } - $date = new Application_Common_DateHelper; - $timeNow = $date->getTimestamp(); - $utcTimeNow = $date->getUtcTimestamp(); + $displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone()); + $displayNow = new DateTime("now", $displayTimeZone); + + $utcNow = clone $displayNow; + $utcNow->setTimezone(new DateTimeZone("UTC")); - $shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow); + $shows = Application_Model_Show::getPrevCurrentNext($utcNow->format("Y-m-d H:i:s")); $previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null; $currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][0]['instance_id']:null; $nextShowID = count($shows['nextShow'])>0?$shows['nextShow'][0]['instance_id']:null; - $results = self::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow); + $results = self::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcNow->format("Y-m-d H:i:s")); $range = array("env"=>APPLICATION_ENV, - "schedulerTime"=>$timeNow, + "schedulerTime"=> $displayNow->format("Y-m-d H:i:s"), "previous"=>$results['previous'] !=null?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null), "current"=>$results['current'] !=null?$results['current']:((count($shows['currentShow'])>0 && $shows['currentShow'][0]['record'] == 1)?$shows['currentShow'][0]:null), "next"=> $results['next'] !=null?$results['next']:(count($shows['nextShow'])>0?$shows['nextShow'][0]:null), "currentShow"=>$shows['currentShow'], "nextShow"=>$shows['nextShow'], - "timezone"=> date("T"), - "timezoneOffset"=> date("Z") + "timezone"=> $displayNow->format("T"), + "timezoneOffset"=> $displayNow->format("Z") ); return $range;