\Horde_ActiveSync_Timezone

Utility functions for dealing with Microsoft ActiveSync's Timezone format.

Copyright 2009-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE 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).

Summary

Methods
Properties
Constants
getOffsetsFromSyncTZ()
getSyncTZFromOffsets()
getOffsetsFromDate()
getTimezone()
getListOfTimezones()
No public properties found
No constants found
_getTransitions()
_generateOffsetsForTransition()
_setDefaultStartDate()
_checkTimezone()
_checkTransition()
_isNthOcurrenceOfWeekdayInMonth()
_chbo()
$_startDate
N/A
No private methods found
No private properties found
N/A

Properties

$_startDate

$_startDate : \Horde_Date

Date to use as start date when iterating through offsets looking for a transition.

Type

\Horde_Date

Methods

getOffsetsFromSyncTZ()

getOffsetsFromSyncTZ(  $data) : array

Convert a timezone from the ActiveSync base64 structure to a TZ offset hash.

Parameters

$data

Returns

array —

Hash of offset information

getSyncTZFromOffsets()

getSyncTZFromOffsets(array  $offsets) : string

Build an ActiveSync TZ blob given a TZ Offset hash.

Parameters

array $offsets

A TZ offset hash

Returns

string —

A base64_encoded ActiveSync Timezone structure suitable for transmitting via wbxml.

getOffsetsFromDate()

getOffsetsFromDate(\Horde_Date  $date) : array

Create a offset hash suitable for use in ActiveSync transactions

Parameters

\Horde_Date $date

A date object representing the date to base the the tz data on.

Returns

array —

An offset hash.

getTimezone()

getTimezone(array|string  $offsets, string  $expectedTimezone = null) : string

Attempt to guess the timezone identifier from the $offsets array.

Parameters

array|string $offsets

The timezone to check. Either an array of offsets or an activesynz tz blob.

string $expectedTimezone

The expected timezone. If not empty, and present in the results, will return.

Returns

string —

The timezone identifier

getListOfTimezones()

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.

Parameters

array|string $offsets

Either an offset array, or a AS timezone structure.

string $expectedTimezone

The expected timezone.

Returns

array —

An array of timezone identifiers

_getTransitions()

_getTransitions(\DateTimeZone  $timezone, \Horde_Date  $date) : array

Get the transition data for moving from DST to STD time.

Parameters

\DateTimeZone $timezone

The timezone to get the transition for

\Horde_Date $date

The date to start from. Really only the year we are interested in is needed.

Returns

array —

An array containing the the STD and DST transitions

_generateOffsetsForTransition()

_generateOffsetsForTransition(array  $offsets, array  $transition, string  $type) : array

Calculate the offsets for the specified transition

Parameters

array $offsets

A TZ offset hash

array $transition

A transition hash

string $type

Transition type - dst or std

Returns

array —

A populated offset hash

_setDefaultStartDate()

_setDefaultStartDate(array  $offsets = null) 

Set default value for $_startDate.

Tries to guess the correct startDate depending on object property falls back to current date.

Parameters

array $offsets

Offsets may be avaluated for a given start year

_checkTimezone()

_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.

Parameters

\DateTimeZone $timezone

The timezone to check.

array $offsets

The offsets to check.

Returns

array|boolean —

An array of transition data or false if timezone does not match offset.

_checkTransition()

_checkTransition(array  $std, array  $dst, array  $offsets) : boolean

Check if the given standardTransition and daylightTransition match to the given offsets.

Parameters

array $std

The Standard transition date.

array $dst

The DST transition date.

array $offsets

The offsets to check.

Returns

boolean

_isNthOcurrenceOfWeekdayInMonth()

_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.

Parameters

integer $timestamp

The timestamp to check.

integer $occurence

1 to 5, where 5 indicates the final occurrence during the month if that day of the week does not occur 5 times

Returns

boolean

_chbo()

_chbo(integer  $num) : integer

Change the byte order of a number. Used to allow big endian machines to decode the timezone blobs, which are encoded in little endian order.

Parameters

integer $num

The number to reverse.

Returns

integer —

The number, in the reverse byte order.