Horde_Mapi_Timezone::getListOfTimezones PHP Method

getListOfTimezones() public method

Get the list of timezone identifiers that match the given offsets, having a preference for $expectedTimezone if it's present in the results.
public getListOfTimezones ( array | string $offsets, string $expectedTimezone = null ) : array
$offsets array | string Either an offset array, or a AS timezone structure.
$expectedTimezone string The expected timezone.
return array An array of timezone identifiers
    public function getListOfTimezones($offsets, $expectedTimezone = null)
    {
        if (is_string($offsets)) {
            $offsets = self::getOffsetsFromSyncTZ($offsets);
        }
        $this->_setDefaultStartDate($offsets);
        $timezones = array();
        foreach (DateTimeZone::listIdentifiers() as $timezoneIdentifier) {
            $timezone = new DateTimeZone($timezoneIdentifier);
            if (false !== ($matchingTransition = $this->_checkTimezone($timezone, $offsets))) {
                if ($timezoneIdentifier == $expectedTimezone) {
                    $timezones = array($timezoneIdentifier => $matchingTransition['abbr']);
                    break;
                } else {
                    $timezones[$timezoneIdentifier] = $matchingTransition['abbr'];
                }
            }
        }
        if (empty($timezones)) {
            throw new Horde_Mapi_Exception('No timezone found for the given offsets');
        }
        return $timezones;
    }