/**
 * Get WordPress timezone setting.
 *
 * Always returns a valid timezone string even when the setting is a GMT offset.
 *
 * @since  3.0.0
 *
 * @return null|string
 */
function simcal_get_wp_timezone()
{
    $timezone = get_option('timezone_string');
    if (empty($timezone)) {
        $gmt = get_option('gmt_offset');
        $timezone = simcal_get_timezone_from_gmt_offset($gmt);
    }
    return $timezone;
}
 /**
  * Set the timezone.
  *
  * @since 3.0.0
  *
  * @param string $tz Timezone.
  */
 public function set_timezone($tz = '')
 {
     $site_tz = esc_attr(simcal_get_wp_timezone());
     if ($this->feed === 'grouped-calendars') {
         $this->timezone = $site_tz;
         return;
     }
     if (empty($tz)) {
         $timezone_setting = get_post_meta($this->id, '_feed_timezone_setting', true);
         if ('use_site' == $timezone_setting) {
             $tz = $site_tz;
         } elseif ('use_custom' == $timezone_setting) {
             $custom_timezone = esc_attr(get_post_meta($this->id, '_feed_timezone', true));
             // One may be using a non standard timezone in GMT (UTC) offset format.
             if (strpos($custom_timezone, 'UTC+') === 0 || strpos($custom_timezone, 'UTC-') === 0) {
                 $tz = simcal_get_timezone_from_gmt_offset(substr($custom_timezone, 3));
             } else {
                 $tz = !empty($custom_timezone) ? $custom_timezone : 'UTC';
             }
         }
         $this->timezone = empty($tz) ? 'UTC' : $tz;
         return;
     }
     $this->site_timezone = $site_tz;
     $this->timezone = simcal_esc_timezone($tz, $this->timezone);
 }