41 include_once(
'Services/Calendar/classes/class.ilTimeZoneException.php');
72 $this->timezone = $a_timezone;
79 if(!self::$server_timezone)
84 if(!self::$default_timezone)
119 if(isset(self::$instances[$a_tz]))
121 $instance = self::$instances[$a_tz];
125 $instance = self::$instances[$a_tz] =
new ilTimeZone($a_tz);
129 if(!$instance->validateTZ())
151 $this->log->write(__METHOD__.
': Unsupported timezone given: Timzone: '.$this->timezone);
171 $this->log->write(__METHOD__.
': Unsupported timezone given: Timzone: '.$this->timezone);
203 if(self::$current_timezone == $a_timezone)
205 #$ilLog->write(__METHOD__.': Do not switch to active timezone: '.$a_timezone);
210 if(function_exists(
'date_default_timezone_set'))
212 if(!date_default_timezone_set($a_timezone))
214 $ilLog->write(__METHOD__.
': Invalid timezone given. Timezone: '.$a_timezone);
217 #$ilLog->write(__METHOD__.': Switched timezone to: '.$a_timezone);
218 self::$current_timezone = $a_timezone;
221 if(!putenv(
'TZ='.$a_timezone))
223 $ilLog->write(__METHOD__.
': Cannot set TZ environment variable. Please register TZ in php.ini (safe_mode_allowed_env_vars). Timezone');
226 self::$current_timezone = $a_timezone;
241 if(!self::$server_timezone)
246 self::$default_timezone = $a_tz;
272 if(strlen(self::$default_timezone))
277 if(function_exists(
'date_default_timezone_get') and $tz = @date_default_timezone_get())
279 return self::$default_timezone = $tz;
282 if($tz = ini_get(
'date.timezone'))
284 return self::$default_timezone = $tz;
287 if($tz = getenv(
'PHP_TZ'))
289 return self::$default_timezone = $tz;
292 if($tz = getenv(
'TZ'))
294 return self::$default_timezone = $tz;
296 if(strlen($tz = date(
'T')))
298 return self::$default_timezone = $tz;
300 return self::$default_timezone =
self::UTC;