* @return string Timezone e.g. 'America/Los_Angeles'
*/
function getTimeZoneString() {
- return NULL;
+ return date_default_timezone_get();
}
/**
}
/**
- * Get timezone from Drupal
- * @return boolean|string
+ * Over-ridable function to get timezone as a string eg.
+ * @return string Timezone e.g. 'America/Los_Angeles'
*/
- function getTimeZoneOffset(){
+ function getTimeZoneString() {
global $user;
if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
$timezone = $user->timezone;
} else {
$timezone = variable_get('date_default_timezone', null);
}
- $tzObj = new DateTimeZone($timezone);
- $dateTime = new DateTime("now", $tzObj);
- $tz = $tzObj->getOffset($dateTime);
-
- if(empty($tz)){
- return false;
- }
-
- $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz/60)%60));
-
- if($timeZoneOffset > 0){
- $timeZoneOffset = '+' . $timeZoneOffset;
+ if (!$timezone) {
+ $timezone = parent::getTimeZoneString();
}
- return $timeZoneOffset;
+ return $timezone;
}
/**
* Reset any system caches that may be required for proper CiviCRM
}
/**
- * Get timezone from Drupal
- * @return boolean|string
+ * Over-ridable function to get timezone as a string eg.
+ * @return string Timezone e.g. 'America/Los_Angeles'
*/
- function getTimeZoneOffset(){
+ function getTimeZoneString() {
global $user;
if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
$timezone = $user->timezone;
} else {
$timezone = variable_get('date_default_timezone', null);
}
- if(empty($timezone)){
- return false;
+ if (!$timezone) {
+ $timezone = parent::getTimeZoneString();
}
- $hour = $user->timezone / 3600;
- $timeZoneOffset = sprintf("%02d:%02d", $timezone / 3600, abs(($timeZoneOffset/60)%60));
- if($timeZoneOffset > 0){
- $timeZoneOffset = '+' . $timeZoneOffset;
- }
- return $timeZoneOffset;
+ return $timezone;
}
throw new Exception("Method not implemented: getLoginURL");
}
+ /**
+ * Over-ridable function to get timezone as a string eg.
+ * @return string Timezone e.g. 'America/Los_Angeles'
+ */
+ function getTimeZoneString() {
+ // This class extends Drupal, but we don't want Drupal's behavior; reproduce CRM_Utils_System_Base::getTimeZoneString
+ return date_default_timezone_get();
+ }
}