Documentation

Horde_ActiveSync_Timezone
in package

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. If you did not receive this file, see http://www.horde.org/licenses/gpl.

Code dealing with searching for a timezone identifier from an AS timezone blob inspired by code in the Tine20 Project (http://tine20.org).

Tags
license

http://www.horde.org/licenses/gpl GPLv2

copyright

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

author

Michael J Rubinsky mrubinsk@horde.org

deprecated

To be removed for Horde 6. Use Horde_Mapi_Timezone::.

Table of Contents

$_startDate  : Horde_Date
Date to use as start date when iterating through offsets looking for a transition.
getListOfTimezones()  : array<string|int, mixed>
Get the list of timezone identifiers that match the given offsets, having a preference for $expectedTimezone if it's present in the results.
getOffsetsFromDate()  : array<string|int, mixed>
Create a offset hash suitable for use in ActiveSync transactions
getOffsetsFromSyncTZ()  : array<string|int, mixed>
Convert a timezone from the ActiveSync base64 structure to a TZ offset hash.
getSyncTZFromOffsets()  : string
Build an ActiveSync TZ blob given a TZ Offset hash.
getTimezone()  : string
Attempt to guess the timezone identifier from the $offsets array.
_chbo()  : int
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.
_checkTimezone()  : array<string|int, mixed>|bool
Check if the given timezone matches the offsets and also evaluate the daylight saving time transitions for this timezone if necessary.
_checkTransition()  : bool
Check if the given standardTransition and daylightTransition match to the given offsets.
_generateOffsetsForTransition()  : array<string|int, mixed>
Calculate the offsets for the specified transition
_getTransitions()  : array<string|int, mixed>
Get the transition data for moving from DST to STD time.
_isNthOcurrenceOfWeekdayInMonth()  : bool
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()  : mixed
Set default value for $_startDate.

Properties

$_startDate

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

protected Horde_Date $_startDate

Methods

getListOfTimezones()

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|int, mixed>|string $offsets[, string $expectedTimezone = null ]) : array<string|int, mixed>
Parameters
$offsets : array<string|int, mixed>|string

Either an offset array, or a AS timezone structure.

$expectedTimezone : string = null

The expected timezone.

Return values
array<string|int, mixed>

An array of timezone identifiers

getOffsetsFromDate()

Create a offset hash suitable for use in ActiveSync transactions

public static getOffsetsFromDate(Horde_Date $date) : array<string|int, mixed>
Parameters
$date : Horde_Date

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

Return values
array<string|int, mixed>

An offset hash.

getOffsetsFromSyncTZ()

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

public static getOffsetsFromSyncTZ(mixed $data) : array<string|int, mixed>
Parameters
$data : mixed
Return values
array<string|int, mixed>

Hash of offset information

getSyncTZFromOffsets()

Build an ActiveSync TZ blob given a TZ Offset hash.

public static getSyncTZFromOffsets(array<string|int, mixed> $offsets) : string
Parameters
$offsets : array<string|int, mixed>

A TZ offset hash

Return values
string

A base64_encoded ActiveSync Timezone structure suitable for transmitting via wbxml.

getTimezone()

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

public getTimezone(array<string|int, mixed>|string $offsets[, string $expectedTimezone = null ]) : string
Parameters
$offsets : array<string|int, mixed>|string

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

$expectedTimezone : string = null

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

Return values
string

The timezone identifier

_chbo()

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.

protected static _chbo(int $num) : int
Parameters
$num : int

The number to reverse.

Return values
int

The number, in the reverse byte order.

_checkTimezone()

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<string|int, mixed> $offsets) : array<string|int, mixed>|bool
Parameters
$timezone : DateTimeZone

The timezone to check.

$offsets : array<string|int, mixed>

The offsets to check.

Return values
array<string|int, mixed>|bool

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

_checkTransition()

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

protected _checkTransition(array<string|int, mixed> $std, array<string|int, mixed> $dst, array<string|int, mixed> $offsets) : bool
Parameters
$std : array<string|int, mixed>

The Standard transition date.

$dst : array<string|int, mixed>

The DST transition date.

$offsets : array<string|int, mixed>

The offsets to check.

Return values
bool

_generateOffsetsForTransition()

Calculate the offsets for the specified transition

protected static _generateOffsetsForTransition(array<string|int, mixed> $offsets, array<string|int, mixed> $transition, string $type) : array<string|int, mixed>
Parameters
$offsets : array<string|int, mixed>

A TZ offset hash

$transition : array<string|int, mixed>

A transition hash

$type : string

Transition type - dst or std

Return values
array<string|int, mixed>

A populated offset hash

_getTransitions()

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

protected static _getTransitions(DateTimeZone $timezone, Horde_Date $date) : array<string|int, mixed>
Parameters
$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 values
array<string|int, mixed>

An array containing the the STD and DST transitions

_isNthOcurrenceOfWeekdayInMonth()

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(int $timestamp, int $occurence) : bool
Parameters
$timestamp : int

The timestamp to check.

$occurence : int

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

Return values
bool

_setDefaultStartDate()

Set default value for $_startDate.

protected _setDefaultStartDate([array<string|int, mixed> $offsets = null ]) : mixed

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

Parameters
$offsets : array<string|int, mixed> = null

Offsets may be avaluated for a given start year

Return values
mixed

Search results