Documentation

Horde_Timezone_Rule
in package

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.

Tags
author

Jan Schneider jan@horde.org

Table of Contents

$_name  : string
A ruleset name.
$_rules  : array<string|int, mixed>
All Rule lines for this ruleset.
$_weekdays  : array<string|int, mixed>
List to map weekday descriptions used in the timezone database.
__construct()  : mixed
Constructor.
add()  : mixed
Adds a Rule line to this ruleset.
addRules()  : mixed
Adds rules from this ruleset to a VTIMEZONE component.
_findPreviousOffset()  : int
Finds the offset of a previous rule.
_getDiff()  : int
Helper method to calculate the difference in days between a date and the occurence of rule.
_getFirstMatch()  : Horde_Date
Finds a date matching a rule definition.
_getOffset()  : array<string|int, mixed>
Calculates the new offset of a timezone.
_setTime()  : mixed

Properties

$_name

A ruleset name.

protected string $_name

$_rules

All Rule lines for this ruleset.

protected array<string|int, mixed> $_rules = array()

$_weekdays

List to map weekday descriptions used in the timezone database.

protected array<string|int, mixed> $_weekdays = array('Mon' => \Horde_Date::DATE_MONDAY, 'Tue' => \Horde_Date::DATE_TUESDAY, 'Wed' => \Horde_Date::DATE_WEDNESDAY, 'Thu' => \Horde_Date::DATE_THURSDAY, 'Fri' => \Horde_Date::DATE_FRIDAY, 'Sat' => \Horde_Date::DATE_SATURDAY, 'Sun' => \Horde_Date::DATE_SUNDAY)

Methods

__construct()

Constructor.

public __construct(string $name) : mixed
Parameters
$name : string

A ruleset name.

Return values
mixed

add()

Adds a Rule line to this ruleset.

public add(array<string|int, mixed> $rule) : mixed
Parameters
$rule : array<string|int, mixed>

A parsed Rule line.

Return values
mixed

addRules()

Adds rules from this ruleset to a VTIMEZONE component.

public addRules(Horde_Icalendar_Vtimezone $tz, string $tzid, string $name, array<string|int, mixed> $startOffset, Horde_Date $start[, Horde_Date $end = null ]) : mixed
Parameters
$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<string|int, mixed>

An offset hash describing the base offset of a timezone.

$start : Horde_Date

Start of the period to add rules for.

$end : Horde_Date = null

End of the period to add rules for.

Return values
mixed

_findPreviousOffset()

Finds the offset of a previous rule.

protected _findPreviousOffset(Horde_Date $date, int $ruleNo, int $startOffset) : int

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
$date : Horde_Date

The start date of the current rule.

$ruleNo : int

The rule number of the current rule.

$startOffset : int

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

Return values
int

The offset of the last rule before the current.

_getDiff()

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

protected _getDiff(int $ruleNo, Horde_Date $date, int $year) : int
Parameters
$ruleNo : int

A rule number.

$date : Horde_Date

A date.

$year : int

A year.

Return values
int

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

_getFirstMatch()

Finds a date matching a rule definition.

protected _getFirstMatch(array<string|int, mixed> $rule, int $year) : Horde_Date
Parameters
$rule : array<string|int, mixed>

A rule definition hash from addRules().

$year : int

A year when the rule should be applied.

Return values
Horde_Date

The first matching date.

_getOffset()

Calculates the new offset of a timezone.

protected _getOffset(array<string|int, mixed> $start, string $new) : array<string|int, mixed>
Parameters
$start : array<string|int, mixed>

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 values
array<string|int, mixed>

A hash describing the new timezone offset.

_setTime()

protected _setTime(mixed $date, mixed $hour, mixed $minute, mixed $modifier[, mixed $utc = false ]) : mixed
Parameters
$date : mixed
$hour : mixed
$minute : mixed
$modifier : mixed
$utc : mixed = false
Return values
mixed

Search results