ActionScheduler_TimezoneHelper::get_local_timezone()public staticWC 1.0

Устарела с версии 2.1.0. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.

Метод класса: ActionScheduler_TimezoneHelper{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = ActionScheduler_TimezoneHelper::get_local_timezone( $reset );
$reset **
-
По умолчанию: FALSE

Список изменений

Устарела с 2.1.0

Код ActionScheduler_TimezoneHelper::get_local_timezone() WC 8.7.0

public static function get_local_timezone( $reset = FALSE ) {
	_deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' );
	if ( $reset ) {
		self::$local_timezone = NULL;
	}
	if ( !isset(self::$local_timezone) ) {
		$tzstring = get_option('timezone_string');

		if ( empty($tzstring) ) {
			$gmt_offset = get_option('gmt_offset');
			if ( $gmt_offset == 0 ) {
				$tzstring = 'UTC';
			} else {
				$gmt_offset *= HOUR_IN_SECONDS;
				$tzstring   = timezone_name_from_abbr( '', $gmt_offset, 1 );

				// If there's no timezone string, try again with no DST.
				if ( false === $tzstring ) {
					$tzstring = timezone_name_from_abbr( '', $gmt_offset, 0 );
				}

				// Try mapping to the first abbreviation we can find.
				if ( false === $tzstring ) {
					$is_dst = date( 'I' );
					foreach ( timezone_abbreviations_list() as $abbr ) {
						foreach ( $abbr as $city ) {
							if ( $city['dst'] == $is_dst && $city['offset'] == $gmt_offset ) {
								// If there's no valid timezone ID, keep looking.
								if ( null === $city['timezone_id'] ) {
									continue;
								}

								$tzstring = $city['timezone_id'];
								break 2;
							}
						}
					}
				}

				// If we still have no valid string, then fall back to UTC.
				if ( false === $tzstring ) {
					$tzstring = 'UTC';
				}
			}
		}

		self::$local_timezone = new DateTimeZone($tzstring);
	}
	return self::$local_timezone;
}