original_string: public static function get_user_timezone($userorforcedtz = null) {
          global $USER, $CFG;
  
          if ($userorforcedtz instanceof DateTimeZone) {
              return $userorforcedtz->getName();
          }
  
          if (isset($userorforcedtz) and !is_object($userorforcedtz) and $userorforcedtz != 99) {
              // Legacy code is forcing timezone in legacy API.
              return self::normalise_timezone($userorforcedtz);
          }
  
          if (isset($CFG->forcetimezone) and $CFG->forcetimezone != 99) {
              // Override any user timezone.
              return self::normalise_timezone($CFG->forcetimezone);
          }
  
          if ($userorforcedtz === null) {
              $tz = isset($USER->timezone) ? $USER->timezone : 99;
  
          } else if (is_object($userorforcedtz)) {
              $tz = isset($userorforcedtz->timezone) ? $userorforcedtz->timezone : 99;
  
          } else {
              if ($userorforcedtz == 99) {
                  $tz = isset($USER->timezone) ? $USER->timezone : 99;
              } else {
                  $tz = $userorforcedtz;
              }
          }
  
          if ($tz == 99) {
              return self::get_server_timezone();
          }
  
          return self::normalise_timezone($tz);
      }
code: public static function get_user_timezone($userorforcedtz = null) {
          global $USER, $CFG;
  
          if ($userorforcedtz instanceof DateTimeZone) {
              return $userorforcedtz->getName();
          }
  
          if (isset($userorforcedtz) and !is_object($userorforcedtz) and $userorforcedtz != 99) {
              // Legacy code is forcing timezone in legacy API.
              return self::normalise_timezone($userorforcedtz);
          }
  
          if (isset($CFG->forcetimezone) and $CFG->forcetimezone != 99) {
              // Override any user timezone.
              return self::normalise_timezone($CFG->forcetimezone);
          }
  
          if ($userorforcedtz === null) {
              $tz = isset($USER->timezone) ? $USER->timezone : 99;
  
          } else if (is_object($userorforcedtz)) {
              $tz = isset($userorforcedtz->timezone) ? $userorforcedtz->timezone : 99;
  
          } else {
              if ($userorforcedtz == 99) {
                  $tz = isset($USER->timezone) ? $USER->timezone : 99;
              } else {
                  $tz = $userorforcedtz;
              }
          }
  
          if ($tz == 99) {
              return self::get_server_timezone();
          }
  
          return self::normalise_timezone($tz);
      }
code_tokens: public static function get_user_timezone ( $ userorforcedtz = null ) { global $ USER , $ CFG ; if ( $ userorforcedtz instanceof DateTimeZone ) { return $ userorforcedtz -> getName ( ) ; } if ( isset ( $ userorforcedtz ) and ! is_object ( $ userorforcedtz ) and $ userorforcedtz != 99 ) { // Legacy code is forcing timezone in legacy API. return self :: normalise_timezone ( $ userorforcedtz ) ; } if ( isset ( $ CFG -> forcetimezone ) and $ CFG -> forcetimezone != 99 ) { // Override any user timezone. return self :: normalise_timezone ( $ CFG -> forcetimezone ) ; } if ( $ userorforcedtz === null ) { $ tz = isset ( $ USER -> timezone ) ? $ USER -> timezone : 99 ; } else if ( is_object ( $ userorforcedtz ) ) { $ tz = isset ( $ userorforcedtz -> timezone ) ? $ userorforcedtz -> timezone : 99 ; } else { if ( $ userorforcedtz == 99 ) { $ tz = isset ( $ USER -> timezone ) ? $ USER -> timezone : 99 ; } else { $ tz = $ userorforcedtz ; } } if ( $ tz == 99 ) { return self :: get_server_timezone ( ) ; } return self :: normalise_timezone ( $ tz ) ; }
docstring: Returns user timezone.
  
  Ideally the parameter should be a real user record,
  unfortunately the legacy code is using 99 for both server
  and default value.
  
  Example of using legacy API:
  // Date for other user via legacy API.
  $datestr = userdate($time, core_date::get_user_timezone($user));
  
  The coding style rules in Moodle are moronic,
  why cannot the parameter names have underscores in them?
  
  @param mixed $userorforcedtz user object or legacy forced timezone string or tz object
  @return string normalised timezone name compatible with PHP
docstring_tokens: Returns user timezone .