Set timezone.

@param  string  default
@return bool
170879
public function setTimezone($default) {
        /*
        I'm sure I'm not the only one who is distressed by the recent default behavior change to E_NOTICE when the timezone isn't explicitly set in the program or in .ini.  I insure that the clock on the server IS correct, and I don't want to have to set it in two places (the system AND PHP).  So I want to read it from the system.  But PHP won't accept that answer, and insists on a call to this function
        Use it by calling it with a fallback default answer. It doesn't work on Windows.
        */
        $timezone = "";
    
        // On many systems (Mac, for instance) "/etc/localtime" is a symlink
        // to the file with the timezone info
        if (is_link("/etc/localtime")) {
        
            // If it is, that file's name is actually the "Olsen" format timezone
            $filename = readlink("/etc/localtime");
        
            $pos = strpos($filename, "zoneinfo");
            if ($pos) {
                // When it is, it's in the "/usr/share/zoneinfo/" folder
                $timezone = substr($filename, $pos + strlen("zoneinfo/"));
            }
            else {
                // If not, bail
                $timezone = $default;
            }
        }
        elseif (is_link("/etc/timezone")) {
            // On other systems, like Ubuntu, there's file with the Olsen time
            // right inside it.
            $timezone = file_get_contents("/etc/timezone");
            if (!strlen($timezone)) {
                $timezone = $default;
            }
        }
        else {
            $timezone = $default;
        }
        date_default_timezone_set($timezone);
    }
796930
def SetTimezone(self, timezone):
    
    if not timezone:
      return

    try:
      self._timezone = pytz.timezone(timezone)
    except pytz.UnknownTimeZoneError:
      raise ValueError('Unsupported timezone: {0:s}'.format(timezone))
523916
private void setDefaultTimeZone() {
        String tzName = System.getProperty("use.time.zone");
        if ( tzName == null ) return;   // Use OS/user default.
        //
        // If tzName is bogus, not understood by the JRE,
        // 'getTimeZone' returns GMT.
        //
        TimeZone toSet = TimeZone.getTimeZone( tzName );
        //
        // Set default to whatever was returned.
        //
        TimeZone.setDefault( toSet );
    }
1048626
public synchronized static void setDefault(TimeZone timeZone) {
        defaultTimeZone = timeZone != null ? (TimeZone) timeZone.clone() : null;
    }
1152735
public static function timezone($timezone = null): \DateTimeZone
    {
        if ($timezone instanceof DateTimeZone) {
            return $timezone;
        }

        $timezone = $timezone ?: date_default_timezone_get();

        return new DateTimeZone($timezone);
    }
682083
public void setTimeZone(TimeZone tz)
    {
        setTzFormatString(tz);        
        if( _locale != null ) 
        {
            _tzFormat=new SimpleDateFormat(_tzFormatString,_locale);
            _minFormat=new SimpleDateFormat(_minFormatString,_locale);
        }
        else if( _dfs != null ) 
        {
            _tzFormat=new SimpleDateFormat(_tzFormatString,_dfs);
            _minFormat=new SimpleDateFormat(_minFormatString,_dfs);
        }
        else 
        {
            _tzFormat=new SimpleDateFormat(_tzFormatString);
            _minFormat=new SimpleDateFormat(_minFormatString);
        }
        _tzFormat.setTimeZone(tz);
        _minFormat.setTimeZone(tz);
        _lastSeconds=-1;
        _lastMinutes=-1;        
    }
734273
def set_timezone(self, request, org):
        """"""
        if org and org.timezone:
            timezone.activate(org.timezone)
402655
public function setTimezone($timezone = 'UTC')
	{
		$this->current->setTimezone(is_string($timezone) ? new \DateTimeZone($timezone) : $timezone);
		return $this;
	}
612428
public function setDateFromDateTime(DateTime $date = NULL, DateTimeZone $dateTimeZone = NULL) {
    $dateTimeZone = !empty($dateTimeZone) ? $dateTimeZone : new DateTimeZone('UTC');
    $this->date = !empty($date) ? $date : new DateTime($date);
    $this->date->setTimezone($dateTimeZone);
  }
492826
function vtimezone( $timezonetype=FALSE ) {
    if( !$timezonetype )
      $this->timezonetype = 'VTIMEZONE';
    else
      $this->timezonetype = strtoupper( $timezonetype );
    $this->calendarComponent();
  }
153094
private static function time()
    {
        $files = ['DateTime'];
        $folder = static::$root.'Time'.'/';

        self::call($files, $folder);

        DateTime::setTimezone();
    }
697180
protected function changeTimezone()
    {
        $this->previousTimezone=false;
        if ($this->timezone) {
            $this->previousTimezone=date_default_timezone_get();
            date_default_timezone_set($this->timezone);
        }
    }
1022021
public static function timezone()
    {
        if (!self::isDebug()) {
            return false;
        }

        $data = date_default_timezone_get();
        return self::i()->dump($data, '! timezone !');
    }
166916
public static function setLocale($default = null)
    {
        $locale = self::extractLocale($default);
        Logger::log('Set locale to project [' . $locale . ']');
        // Load translations
        putenv("LC_ALL=" . $locale);
        setlocale(LC_ALL, $locale);
        // Load the locale path
        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
        Logger::log('Set locale dir ' . $locale_path);
        GeneratorHelper::createDir($locale_path);
        bindtextdomain('translations', $locale_path);
        textdomain('translations');
        bind_textdomain_codeset('translations', 'UTF-8');
        Security::getInstance()->setSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY, substr($locale, 0, 2));
    }
331805
public static function set_default_server_timezone() {
        global $CFG;

        if (!isset($CFG->timezone) or $CFG->timezone == 99 or $CFG->timezone === '') {
            date_default_timezone_set(self::get_default_php_timezone());
            return;
        }

        $current = date_default_timezone_get();
        if ($current === $CFG->timezone) {
            // Nothing to do.
            return;
        }

        if (!isset(self::$goodzones)) {
            // For better performance try do do this without full tz init,
            // because this is called from lib/setup.php file on each page.
            $result = @timezone_open($CFG->timezone); // Ignore error if setting invalid.
            if ($result !== false) {
                date_default_timezone_set($result->getName());
                return;
            }
        }

        // Slow way is the last option.
        date_default_timezone_set(self::get_server_timezone());
    }
732164
public function setTZ(DateTimeZone $time_zone)
    {
        $this->addSeconds($this->format('Z'));
        $result = $this->setTimezone($time_zone);
        $this->subtractSeconds($this->format('Z'));
        return $result;
    }
414863
public static function useServerDefaultTimezone($boolean = null)
    {
        if ($boolean !== null) {
            self::$useStz = (bool) $boolean;

            return self::$useStz;
        }

        return self::$useStz;
    }