PHP Class Horde_Timezone_Rule, horde

Copyright 2011-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.
Author: Jan Schneider ([email protected])
显示文件 Open project: horde/horde

Protected Properties

Property Type Description
$_name string A ruleset name.
$_rules array All Rule lines for this ruleset.
$_weekdays array List to map weekday descriptions used in the timezone database.

Public Methods

Method Description
__construct ( string $name ) Constructor.
add ( array $rule ) Adds a Rule line to this ruleset.
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.

Protected Methods

Method Description
_findPreviousOffset ( Horde_Date $date, integer $ruleNo, integer $startOffset ) : integer Finds the offset of a previous rule.
_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.
_getFirstMatch ( array $rule, integer $year ) : Horde_Date Finds a date matching a rule definition.
_getOffset ( array $start, string $new ) : array Calculates the new offset of a timezone.
_setTime ( $date, $hour, $minute, $modifier, $utc = false )

Method Details

__construct() public method

Constructor.
public __construct ( string $name )
$name string A ruleset name.

_findPreviousOffset() protected method

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.
protected _findPreviousOffset ( Horde_Date $date, integer $ruleNo, integer $startOffset ) : integer
$date Horde_Date The start date of the current rule.
$ruleNo integer The rule number of the current rule.
$startOffset integer The offset to use for the first rule, and also the default.
return integer The offset of the last rule before the current.

_getDiff() protected method

Helper method to calculate the difference in days between a date and the occurence of rule.
protected _getDiff ( integer $ruleNo, Horde_Date $date, integer $year ) : integer
$ruleNo integer A rule number.
$date Horde_Date A date.
$year integer A year.
return integer The days between the date and the rule occurrence in the year.

_getFirstMatch() protected method

Finds a date matching a rule definition.
protected _getFirstMatch ( array $rule, integer $year ) : Horde_Date
$rule array A rule definition hash from addRules().
$year integer A year when the rule should be applied.
return Horde_Date The first matching date.

_getOffset() protected method

Calculates the new offset of a timezone.
protected _getOffset ( array $start, string $new ) : array
$start array A hash describing the original timezone offset.
$new string A string describing the offset to be added to (or subtracted from) the original offset.
return array A hash describing the new timezone offset.

_setTime() protected method

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

add() public method

Adds a Rule line to this ruleset.
public add ( array $rule )
$rule array A parsed Rule line.

addRules() public method

Adds rules from this ruleset to a VTIMEZONE component.
public addRules ( Horde_Icalendar_Vtimezone $tz, string $tzid, string $name, array $startOffset, Horde_Date $start, Horde_Date $end = null )
$tz Horde_Icalendar_Vtimezone A VTIMEZONE component.
$tzid string The timezone ID of the component.
$name string A timezone name abbreviation. May contain a placeholder that is replaced the Rules' "Letter(s)" entry.
$startOffset array An offset hash describing the base offset of a timezone.
$start Horde_Date Start of the period to add rules for.
$end Horde_Date End of the period to add rules for.

Property Details

$_name protected_oe property

A ruleset name.
protected string $_name
return string

$_rules protected_oe property

All Rule lines for this ruleset.
protected array $_rules
return array

$_weekdays protected_oe property

List to map weekday descriptions used in the timezone database.
protected array $_weekdays
return array