41 include_once(
'Services/Calendar/classes/class.ilTimeZoneException.php');
77 $this->
timezone = self::_getDefaultTimeZone();
80 if(!self::$server_timezone)
82 self::$server_timezone = self::_getDefaultTimeZone();
85 if(!self::$default_timezone)
87 self::_getDefaultTimeZone();
93 return array(
'timezone');
129 $a_tz = self::_getDefaultTimeZone();
132 if(isset(self::$instances[$a_tz]))
134 $instance = self::$instances[$a_tz];
138 $instance = self::$instances[$a_tz] =
new ilTimeZone($a_tz);
142 if(!array_key_exists($instance->getIdentifier(),self::$valid_tz))
144 if(!$instance->validateTZ())
148 self::$valid_tz[$instance->getIdentifier()] =
true;
164 self::_switchTimeZone($this->
timezone);
170 $this->log->write(__METHOD__.
': Unsupported timezone given: Timzone: '.$this->timezone);
184 self::_switchTimeZone(self::$default_timezone);
190 $this->log->write(__METHOD__.
': Unsupported timezone given: Timzone: '.$this->timezone);
222 if(self::$current_timezone == $a_timezone)
224 #$ilLog->write(__METHOD__.': Do not switch to active timezone: '.$a_timezone); 229 if(function_exists(
'date_default_timezone_set'))
231 if(!date_default_timezone_set($a_timezone))
233 $ilLog->write(__METHOD__.
': Invalid timezone given. Timezone: '.$a_timezone);
236 #$ilLog->write(__METHOD__.': Switched timezone to: '.$a_timezone); 237 self::$current_timezone = $a_timezone;
240 if(!putenv(
'TZ='.$a_timezone))
242 $ilLog->write(__METHOD__.
': Cannot set TZ environment variable. Please register TZ in php.ini (safe_mode_allowed_env_vars). Timezone');
245 self::$current_timezone = $a_timezone;
260 if(!self::$server_timezone)
262 self::$server_timezone = self::_getDefaultTimeZone();
265 self::$default_timezone = $a_tz;
278 self::$default_timezone = self::$server_timezone;
279 self::_switchTimeZone(self::$default_timezone);
291 if(strlen(self::$default_timezone))
293 return self::$default_timezone;
297 if(function_exists(
'date_default_timezone_get')
and $tz = @date_default_timezone_get())
299 return self::$default_timezone =
$tz;
302 if(
$tz = ini_get(
'date.timezone'))
304 return self::$default_timezone =
$tz;
307 if(
$tz = getenv(
'PHP_TZ'))
309 return self::$default_timezone =
$tz;
312 if(
$tz = getenv(
'TZ'))
314 return self::$default_timezone =
$tz;
318 return self::$default_timezone =
$tz;
320 return self::$default_timezone = self::UTC;
332 $tz = self::_getDefaultTimeZone();
338 date_default_timezone_set(
$tz);
static _getDefaultTimeZone()
Calculate and set default time zone.
validateTZ()
validate timezone
This class offers methods for timezone handling.
readVariable($a_group, $a_var_name)
reads a single variable from a group public
getIdentifier()
get identifier
switchTZ()
Switch timezone to given timezone.
__construct($a_timezone)
Create new timezone object If no timezone is given, the default server timezone is chosen...
static initDefaultTimeZone(ilIniFile $ini)
Initialize default timezone from system settings.
static _setDefaultTimeZone($a_tz)
set default timezone
restoreTZ()
Restore default timezone.
static _restoreDefaultTimeZone()
restore default timezone to server timezone
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Class for TimeZone exceptions.
Create styles array
The data for the language used.
static _getInstance($a_tz='')
get instance by timezone
static _switchTimeZone($a_timezone)
Switch tz.