\Horde_Timezone_Rule

Class representing a set of "Rule" timezone database entries of the same name.

Copyright 2011-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.

Summary

Methods
Properties
Constants
__construct()
add()
addRules()
No public properties found
No constants found
_getFirstMatch()
_findPreviousOffset()
_setTime()
_getDiff()
_getOffset()
$_name
$_rules
$_weekdays
N/A
No private methods found
No private properties found
N/A

Properties

$_name

$_name : string

A ruleset name.

Type

string

$_rules

$_rules : array

All Rule lines for this ruleset.

Type

array

$_weekdays

$_weekdays : array

List to map weekday descriptions used in the timezone database.

Type

array

Methods

__construct()

__construct(string  $name) 

Constructor.

Parameters

string $name

A ruleset name.

add()

add(array  $rule) 

Adds a Rule line to this ruleset.

Parameters

array $rule

A parsed Rule line.

addRules()

addRules(\Horde_Icalendar_Vtimezone  $tz, string  $tzid, string  $name, array  $startOffset, \Horde_Date  $start, \Horde_Date  $end = null) 

Adds rules from this ruleset to a VTIMEZONE component.

Parameters

\Horde_Icalendar_Vtimezone $tz

A VTIMEZONE component.

string $tzid

The timezone ID of the component.

string $name

A timezone name abbreviation. May contain a placeholder that is replaced the Rules' "Letter(s)" entry.

array $startOffset

An offset hash describing the base offset of a timezone.

\Horde_Date $start

Start of the period to add rules for.

\Horde_Date $end

End of the period to add rules for.

_getFirstMatch()

_getFirstMatch(array  $rule, integer  $year) : \Horde_Date

Finds a date matching a rule definition.

Parameters

array $rule

A rule definition hash from addRules().

integer $year

A year when the rule should be applied.

Returns

\Horde_Date —

The first matching date.

_findPreviousOffset()

_findPreviousOffset(\Horde_Date  $date, integer  $ruleNo, integer  $startOffset) : integer

Finds the offset of a previous rule.

There may be different potential rules that are "before" the current one, and there may even be two sequential daylight rules with different offsets. Thus we go through all earlier rules (as in "before the current rule in the rule definition", because the rules are ordered by start date), and find the one that starts the closest to the start date of the current rule.

Parameters

\Horde_Date $date

The start date of the current rule.

integer $ruleNo

The rule number of the current rule.

integer $startOffset

The offset to use for the first rule, and also the default.

Returns

integer —

The offset of the last rule before the current.

_setTime()

_setTime(  $date,   $hour,   $minute,   $modifier,   $utc = false) 

Parameters

$date
$hour
$minute
$modifier
$utc

_getDiff()

_getDiff(integer  $ruleNo, \Horde_Date  $date, integer  $year) : integer

Helper method to calculate the difference in days between a date and the occurence of rule.

Parameters

integer $ruleNo

A rule number.

\Horde_Date $date

A date.

integer $year

A year.

Returns

integer —

The days between the date and the rule occurrence in the year.

_getOffset()

_getOffset(array  $start, string  $new) : array

Calculates the new offset of a timezone.

Parameters

array $start

A hash describing the original timezone offset.

string $new

A string describing the offset to be added to (or subtracted from) the original offset.

Returns

array —

A hash describing the new timezone offset.