ActionScheduler_TimezoneHelper::get_local_timezone()public staticWC 1.0

Deprecated from version 2.1.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Method of the class: ActionScheduler_TimezoneHelper{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = ActionScheduler_TimezoneHelper::get_local_timezone( $reset );
$reset **
-
Default: FALSE

Changelog

Deprecated since 2.1.0

ActionScheduler_TimezoneHelper::get_local_timezone() code 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;
}