CC-5594 : Remove all date_default_timezone_get()

updating dashbaord information for timezone.
This commit is contained in:
Naomi 2013-12-04 17:54:28 -05:00
parent 8f1e73edf5
commit ed74470803
2 changed files with 10 additions and 45 deletions

View file

@ -111,43 +111,6 @@ class Application_Common_DateHelper
return $this->_dateTime; 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) public static function TimeDiff($time1, $time2)
{ {
return strtotime($time2) - strtotime($time1); return strtotime($time2) - strtotime($time1);

View file

@ -72,25 +72,27 @@ SQL;
return array(); return array();
} }
$date = new Application_Common_DateHelper; $displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$timeNow = $date->getTimestamp(); $displayNow = new DateTime("now", $displayTimeZone);
$utcTimeNow = $date->getUtcTimestamp();
$shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow); $utcNow = clone $displayNow;
$utcNow->setTimezone(new DateTimeZone("UTC"));
$shows = Application_Model_Show::getPrevCurrentNext($utcNow->format("Y-m-d H:i:s"));
$previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null; $previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null;
$currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][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; $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, $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), "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), "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), "next"=> $results['next'] !=null?$results['next']:(count($shows['nextShow'])>0?$shows['nextShow'][0]:null),
"currentShow"=>$shows['currentShow'], "currentShow"=>$shows['currentShow'],
"nextShow"=>$shows['nextShow'], "nextShow"=>$shows['nextShow'],
"timezone"=> date("T"), "timezone"=> $displayNow->format("T"),
"timezoneOffset"=> date("Z") "timezoneOffset"=> $displayNow->format("Z")
); );
return $range; return $range;