41include_once(
'Services/Calendar/classes/class.ilTimeZoneException.php');
72 $this->timezone = $a_timezone;
77 if (!self::$server_timezone) {
81 if (!self::$default_timezone) {
88 return array(
'timezone');
126 if (isset(self::$instances[$a_tz])) {
127 $instance = self::$instances[$a_tz];
129 $instance = self::$instances[$a_tz] =
new ilTimeZone($a_tz);
133 if (!array_key_exists($instance->getIdentifier(), self::$valid_tz)) {
134 if (!$instance->validateTZ()) {
137 self::$valid_tz[$instance->getIdentifier()] =
true;
156 $this->log->write(__METHOD__ .
': Unsupported timezone given: Timzone: ' . $this->timezone);
173 $this->log->write(__METHOD__ .
': Unsupported timezone given: Timzone: ' . $this->timezone);
204 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')) {
211 if (!date_default_timezone_set($a_timezone)) {
212 $ilLog->write(__METHOD__ .
': Invalid timezone given. Timezone: ' . $a_timezone);
215 #$ilLog->write(__METHOD__.': Switched timezone to: '.$a_timezone);
216 self::$current_timezone = $a_timezone;
219 if (!putenv(
'TZ=' . $a_timezone)) {
220 $ilLog->write(__METHOD__ .
': Cannot set TZ environment variable. Please register TZ in php.ini (safe_mode_allowed_env_vars). Timezone');
223 self::$current_timezone = $a_timezone;
238 if (!self::$server_timezone) {
242 self::$default_timezone = $a_tz;
268 if (strlen(self::$default_timezone)) {
273 if (function_exists(
'date_default_timezone_get') and
$tz = @date_default_timezone_get()) {
274 return self::$default_timezone =
$tz;
277 if (
$tz = ini_get(
'date.timezone')) {
278 return self::$default_timezone =
$tz;
281 if (
$tz = getenv(
'PHP_TZ')) {
282 return self::$default_timezone =
$tz;
285 if (
$tz = getenv(
'TZ')) {
286 return self::$default_timezone =
$tz;
289 return self::$default_timezone =
$tz;
291 return self::$default_timezone =
self::UTC;
300 $tz =
$ini->readVariable(
'server',
'timezone');
307 date_default_timezone_set(
$tz);
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
Class for TimeZone exceptions.
This class offers methods for timezone handling.
restoreTZ()
Restore default timezone.
static initDefaultTimeZone(ilIniFile $ini)
Initialize default timezone from system settings.
getIdentifier()
get identifier
static _restoreDefaultTimeZone()
restore default timezone to server timezone
static _getDefaultTimeZone()
Calculate and set default time zone.
static _switchTimeZone($a_timezone)
Switch tz.
static _setDefaultTimeZone($a_tz)
set default timezone
static _getInstance($a_tz='')
get instance by timezone
__construct($a_timezone)
Create new timezone object If no timezone is given, the default server timezone is chosen.
switchTZ()
Switch timezone to given timezone.
validateTZ()
validate timezone