PHP Class Horde_Mapi_Timezone, horde

Copyright 2009-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21. Code dealing with searching for a timezone identifier from an AS timezone blob inspired by code in the Tine20 Project (http://tine20.org).
Author: Michael J Rubinsky ([email protected])
显示文件 Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_startDate Horde_Date Date to use as start date when iterating through offsets looking for a transition.

Public Methods

Method Description
getListOfTimezones ( array | string $offsets, string $expectedTimezone = null ) : array Get the list of timezone identifiers that match the given offsets, having a preference for $expectedTimezone if it's present in the results.
getOffsetsFromDate ( Horde_Date $date ) : array Create a offset hash suitable for use in ActiveSync transactions
getOffsetsFromSyncTZ ( $data ) : array Convert a timezone from the MAPI base64 structure to a TZ offset hash.
getSyncTZFromOffsets ( array $offsets ) : string Build an MAPI TZ blob given a TZ Offset hash.
getTimezone ( array | string $offsets, string $expectedTimezone = null ) : string Attempt to guess the timezone identifier from the $offsets array.

Protected Methods

Method Description
_checkTimezone ( DateTimeZone $timezone, array $offsets ) : array | boolean Check if the given timezone matches the offsets and also evaluate the daylight saving time transitions for this timezone if necessary.
_checkTransition ( array $std, array $dst, array $offsets ) : boolean Check if the given standardTransition and daylightTransition match to the given offsets.
_generateOffsetsForTransition ( array $offsets, array $transition, string $type ) : array Calculate the offsets for the specified transition
_getTransitions ( DateTimeZone $timezone, Horde_Date $date ) : array Get the transition data for moving from DST to STD time.
_isNthOcurrenceOfWeekdayInMonth ( integer $timestamp, integer $occurence ) : boolean Test if the weekday of the given timestamp is the nth occurence of this weekday within its month, where '5' indicates the last occurrence even if there is less than five occurrences.
_setDefaultStartDate ( array $offsets = null ) Set default value for $_startDate.

Method Details

_checkTimezone() protected method

Check if the given timezone matches the offsets and also evaluate the daylight saving time transitions for this timezone if necessary.
protected _checkTimezone ( DateTimeZone $timezone, array $offsets ) : array | boolean
$timezone DateTimeZone The timezone to check.
$offsets array The offsets to check.
return array | boolean An array of transition data or false if timezone does not match offset.

_checkTransition() protected method

Check if the given standardTransition and daylightTransition match to the given offsets.
protected _checkTransition ( array $std, array $dst, array $offsets ) : boolean
$std array The Standard transition date.
$dst array The DST transition date.
$offsets array The offsets to check.
return boolean

_generateOffsetsForTransition() protected static method

Calculate the offsets for the specified transition
protected static _generateOffsetsForTransition ( array $offsets, array $transition, string $type ) : array
$offsets array A TZ offset hash
$transition array A transition hash
$type string Transition type - dst or std
return array A populated offset hash

_getTransitions() protected static method

Get the transition data for moving from DST to STD time.
protected static _getTransitions ( DateTimeZone $timezone, Horde_Date $date ) : array
$timezone DateTimeZone The timezone to get the transition for
$date Horde_Date The date to start from. Really only the year we are interested in is needed.
return array An array containing the the STD and DST transitions

_isNthOcurrenceOfWeekdayInMonth() protected static method

Test if the weekday of the given timestamp is the nth occurence of this weekday within its month, where '5' indicates the last occurrence even if there is less than five occurrences.
protected static _isNthOcurrenceOfWeekdayInMonth ( integer $timestamp, integer $occurence ) : boolean
$timestamp integer The timestamp to check.
$occurence integer 1 to 5, where 5 indicates the final occurrence during the month if that day of the week does not occur 5 times
return boolean

_setDefaultStartDate() protected method

Tries to guess the correct startDate depending on object property. Falls back to current date.
protected _setDefaultStartDate ( array $offsets = null )
$offsets array Offsets may be avaluated for a given start year

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

getOffsetsFromDate() public static method

Create a offset hash suitable for use in ActiveSync transactions
public static getOffsetsFromDate ( Horde_Date $date ) : array
$date Horde_Date A date object representing the date to base the the tz data on.
return array An offset hash.

getOffsetsFromSyncTZ() public static method

Convert a timezone from the MAPI base64 structure to a TZ offset hash.
public static getOffsetsFromSyncTZ ( $data ) : array
return array Hash of offset information

getSyncTZFromOffsets() public static method

Build an MAPI TZ blob given a TZ Offset hash.
public static getSyncTZFromOffsets ( array $offsets ) : string
$offsets array A TZ offset hash
return string A base64_encoded MAPI Timezone structure suitable for transmitting via wbxml.

getTimezone() public method

Since it's impossible to know exactly which olson timezone name a specific set of offsets represent (multiple timezone names may be described by the same offsets for any given year) we allow passing an expected timezone. If this matches one of the timezones that matches the offsets, we return that. Otherwise, we attempt to get the full timezone name from Horde_Date and if that fails, return the abbreviated timezone name of the first timezone that matches the provided offsets.
public getTimezone ( array | string $offsets, string $expectedTimezone = null ) : string
$offsets array | string The timezone to check. Either an array of offsets or an activesynz tz blob.
$expectedTimezone string The expected timezone. If not empty, and present in the results, will return.
return string The timezone identifier.

Property Details

$_startDate protected_oe property

Date to use as start date when iterating through offsets looking for a transition.
protected Horde_Date $_startDate
return Horde_Date