Documentation

Horde_Date_Recurrence

The Horde_Date_Recurrence class implements algorithms for calculating recurrences of events, including several recurrence types, intervals, exceptions, and conversion from and to vCalendar and iCalendar recurrence rules.

All methods expecting dates as parameters accept all values that the Horde_Date constructor accepts, i.e. a timestamp, another Horde_Date object, an ISO time string or a hash.

Tags
author

Jan Schneider jan@horde.org

category

Horde

copyright

2007-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL

Table of Contents

RECUR_DAILY  = 1
Recurs daily.
RECUR_MONTHLY_DATE  = 3
Recurs monthly on the same date.
RECUR_MONTHLY_LAST_WEEKDAY  = 8
Recurs monthly on the same last week day.
RECUR_MONTHLY_WEEKDAY  = 4
Recurs monthly on the same week day.
RECUR_NONE  = 0
No Recurrence
RECUR_WEEKLY  = 2
Recurs weekly.
RECUR_YEARLY_DATE  = 5
Recurs yearly on the same date.
RECUR_YEARLY_DAY  = 6
Recurs yearly on the same day of the year.
RECUR_YEARLY_WEEKDAY  = 7
Recurs yearly on the same week day.
$completions  : array<string|int, mixed>
All the dates this recurrence has been marked as completed.
$exceptions  : array<string|int, mixed>
All the exceptions from recurrence for this event.
$recurCount  : int
The number of recurrences.
$recurData  : int
Any additional recurrence data.
$recurEnd  : Horde_Date
The end date of the recurrence interval.
$recurInterval  : int
The length of time between recurrences. The time unit depends on the recurrence type.
$recurType  : int
The type of recurrence this event follows. RECUR_* constant.
$start  : Horde_Date
The start time of the event.
__construct()  : mixed
Constructor.
addCompletion()  : mixed
Adds a completion to a recurring event.
addException()  : mixed
Adds an exception to a recurring event.
deleteCompletion()  : mixed
Deletes a completion from a recurring event.
deleteException()  : mixed
Deletes an exception from a recurring event.
fromHash()  : mixed
Creates an instance of this class from a hash.
fromKolab()  : bool
Parses the recurrence data from a Kolab hash.
fromRRule10()  : mixed
Parses a vCalendar 1.0 recurrence rule.
fromRRule20()  : mixed
Parses an iCalendar 2.0 recurrence rule.
getCompletions()  : array<string|int, mixed>
Retrieves all the completions for this event.
getExceptions()  : array<string|int, mixed>
Retrieves all the exceptions for this event.
getRecurCount()  : int
Retrieves the number of recurrences of this event.
getRecurEnd()  : Horde_Date
Retrieves the end date of the recurrence interval.
getRecurInterval()  : int
Retrieves the length of time between recurrences of this event.
getRecurName()  : string
Returns a description of this event's recurring type.
getRecurOnDays()  : int
Returns the days this event recurs on.
getRecurStart()  : Horde_Date
Retrieves the start date of the recurrence interval.
getRecurType()  : int
Returns recurrence type of this event.
hasActiveRecurrence()  : bool
Returns whether this event has any date that matches the recurrence rules and is not an exception.
hasCompletion()  : bool
Checks if a completion exists for a given reccurence of an event.
hasException()  : bool
Checks if an exception exists for a given reccurence of an event.
hasRecurCount()  : bool
Returns whether this event has a recurrence with a fixed count.
hasRecurEnd()  : bool
Returns whether this event has a recurrence end.
hasRecurType()  : bool
Returns whether this event has a specific recurrence type.
isEqual()  : bool
Return whether or not this object is equal to another recurrence object.
nextActiveRecurrence()  : Horde_Date|bool
Returns the next active recurrence.
nextRecurrence()  : Horde_Date|bool
Finds the next recurrence of this event that's after $afterDate.
recurOnDay()  : bool
Checks if this event recurs on a given day of the week.
reset()  : mixed
Resets the class properties.
setRecurCount()  : mixed
Sets the number of recurrences of this event.
setRecurEnd()  : mixed
Sets the end date of the recurrence interval.
setRecurInterval()  : mixed
Sets the length of time between recurrences of this event.
setRecurOnDay()  : mixed
Specifies the days this event recurs on.
setRecurStart()  : mixed
Sets the start date of the recurrence interval.
setRecurType()  : mixed
Sets a recurrence type for this event.
toHash()  : array<string|int, mixed>
Returns a hash representing this object.
toJson()  : object
Returns a simple object suitable for json transport representing this object.
toKolab()  : array<string|int, mixed>
Export this object into a Kolab hash.
toRRule10()  : string
Creates a vCalendar 1.0 recurrence rule.
toRRule20()  : string
Creates an iCalendar 2.0 recurrence rule.
toString()  : string
Output a human readable description of the recurrence rule.
_formatExceptionDate()  : string
Returns a correcty formatted exception date for recurring events.
_nextDaily()  : Horde_Date|bool
Finds the next daily recurrence of this event that's after $afterDate.
_nextMonthlyDate()  : Horde_Date|bool
Finds the next monthly recurrence on the same date of this event that's after $afterDate.
_nextMonthlyWeekday()  : Horde_Date|bool
Finds the next monthly recurrence on the same weekday of this event that's after $afterDate.
_nextWeekly()  : Horde_Date|bool
Finds the next weekly recurrence of this event that's after $afterDate.
_nextYearlyDate()  : Horde_Date|bool
Finds the next yearly recurrence on the same date of this event that's after $afterDate.
_nextYearlyDay()  : Horde_Date|bool
Finds the next yearly recurrence on the same day of the year of this event that's after $afterDate.
_nextYearlyWeekday()  : Horde_Date|bool
Finds the next yearly recurrence on the same weekday of this event that's after $afterDate.

Constants

RECUR_DAILY

Recurs daily.

public mixed RECUR_DAILY = 1

RECUR_MONTHLY_DATE

Recurs monthly on the same date.

public mixed RECUR_MONTHLY_DATE = 3

RECUR_MONTHLY_LAST_WEEKDAY

Recurs monthly on the same last week day.

public mixed RECUR_MONTHLY_LAST_WEEKDAY = 8
Tags
since

Horde_Date 2.1.0

RECUR_MONTHLY_WEEKDAY

Recurs monthly on the same week day.

public mixed RECUR_MONTHLY_WEEKDAY = 4

RECUR_NONE

No Recurrence

public mixed RECUR_NONE = ""

RECUR_WEEKLY

Recurs weekly.

public mixed RECUR_WEEKLY = 2

RECUR_YEARLY_DATE

Recurs yearly on the same date.

public mixed RECUR_YEARLY_DATE = 5

RECUR_YEARLY_DAY

Recurs yearly on the same day of the year.

public mixed RECUR_YEARLY_DAY = 6

RECUR_YEARLY_WEEKDAY

Recurs yearly on the same week day.

public mixed RECUR_YEARLY_WEEKDAY = 7

Properties

$completions

All the dates this recurrence has been marked as completed.

public array<string|int, mixed> $completions = array()

$exceptions

All the exceptions from recurrence for this event.

public array<string|int, mixed> $exceptions = array()

$recurCount

The number of recurrences.

public int $recurCount = ull

$recurData

Any additional recurrence data.

public int $recurData = ull

$recurInterval

The length of time between recurrences. The time unit depends on the recurrence type.

public int $recurInterval = 1

$recurType

The type of recurrence this event follows. RECUR_* constant.

public int $recurType = self::RECUR_NONE

Methods

__construct()

Constructor.

public __construct(Horde_Date $start) : mixed
Parameters
$start : Horde_Date

Start of the recurring event.

Return values
mixed

addCompletion()

Adds a completion to a recurring event.

public addCompletion(int $year, int $month, int $mday) : mixed
Parameters
$year : int

The year of the exception.

$month : int

The month of the exception.

$mday : int

The day of the month of the completion.

Return values
mixed

addException()

Adds an exception to a recurring event.

public addException(int $year, int $month, int $mday) : mixed
Parameters
$year : int

The year of the exception.

$month : int

The month of the exception.

$mday : int

The day of the month of the exception.

Return values
mixed

deleteCompletion()

Deletes a completion from a recurring event.

public deleteCompletion(int $year, int $month, int $mday) : mixed
Parameters
$year : int

The year of the exception.

$month : int

The month of the exception.

$mday : int

The day of the month of the completion.

Return values
mixed

deleteException()

Deletes an exception from a recurring event.

public deleteException(int $year, int $month, int $mday) : mixed
Parameters
$year : int

The year of the exception.

$month : int

The month of the exception.

$mday : int

The day of the month of the exception.

Return values
mixed

fromHash()

Creates an instance of this class from a hash.

public static fromHash(array<string|int, mixed> $hash) : mixed
Parameters
$hash : array<string|int, mixed>

A hash of this object.

Tags
since

Horde_Date 2.4.0

see
toHash()
Return values
mixed

fromKolab()

Parses the recurrence data from a Kolab hash.

public fromKolab(array<string|int, mixed> $hash) : bool
Parameters
$hash : array<string|int, mixed>

The hash to convert.

Return values
bool

True if the hash seemed valid, false otherwise.

getCompletions()

Retrieves all the completions for this event.

public getCompletions() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array containing the dates of all the completions in YYYYMMDD form.

getExceptions()

Retrieves all the exceptions for this event.

public getExceptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array containing the dates of all the exceptions in YYYYMMDD form.

getRecurCount()

Retrieves the number of recurrences of this event.

public getRecurCount() : int
Return values
int

The number recurrences.

getRecurEnd()

Retrieves the end date of the recurrence interval.

public getRecurEnd() : Horde_Date
Return values
Horde_Date

The recurrence end.

getRecurInterval()

Retrieves the length of time between recurrences of this event.

public getRecurInterval() : int
Return values
int

The number of seconds between recurrences.

getRecurName()

Returns a description of this event's recurring type.

public getRecurName() : string
Return values
string

Human readable recurring type.

getRecurOnDays()

Returns the days this event recurs on.

public getRecurOnDays() : int
Return values
int

A mask consisting of Horde_Date::MASK_* constants specifying the day(s) this event recurs on.

getRecurStart()

Retrieves the start date of the recurrence interval.

public getRecurStart() : Horde_Date
Return values
Horde_Date

The recurrence start.

getRecurType()

Returns recurrence type of this event.

public getRecurType() : int
Return values
int

A RECUR_* constant.

hasActiveRecurrence()

Returns whether this event has any date that matches the recurrence rules and is not an exception.

public hasActiveRecurrence() : bool
Return values
bool

True if an active recurrence exists.

hasCompletion()

Checks if a completion exists for a given reccurence of an event.

public hasCompletion(int $year, int $month, int $mday) : bool
Parameters
$year : int

The year of the recurrance.

$month : int

The month of the recurrance.

$mday : int

The day of the month of the recurrance.

Return values
bool

True if a completion exists for the given date.

hasException()

Checks if an exception exists for a given reccurence of an event.

public hasException(int $year, int $month, int $mday) : bool
Parameters
$year : int

The year of the reucrance.

$month : int

The month of the reucrance.

$mday : int

The day of the month of the reucrance.

Return values
bool

True if an exception exists for the given date.

hasRecurCount()

Returns whether this event has a recurrence with a fixed count.

public hasRecurCount() : bool
Return values
bool

True if this recurrence has a fixed count.

hasRecurEnd()

Returns whether this event has a recurrence end.

public hasRecurEnd() : bool
Return values
bool

True if this recurrence ends.

hasRecurType()

Returns whether this event has a specific recurrence type.

public hasRecurType(int $recurrence) : bool
Parameters
$recurrence : int

RECUR_* constant of the recurrence type to check for.

Return values
bool

True if the event has the specified recurrence type.

isEqual()

Return whether or not this object is equal to another recurrence object.

public isEqual(Horde_Date_Recurrence $recurrence) : bool

The objects are considered equal if the recurrence rules are the same. This does not take any exceptions into account.

Parameters
$recurrence : Horde_Date_Recurrence

The recurrence object to check equality to.

Tags
since
2.2.0
Return values
bool

True if the recurrence rules are the same.

nextActiveRecurrence()

Returns the next active recurrence.

public nextActiveRecurrence(Horde_Date $afterDate) : Horde_Date|bool
Parameters
$afterDate : Horde_Date

Return events after this date.

Return values
Horde_Date|bool

The date of the next active recurrence or false if the event has no active recurrence after $afterDate.

nextRecurrence()

Finds the next recurrence of this event that's after $afterDate.

public nextRecurrence(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

recurOnDay()

Checks if this event recurs on a given day of the week.

public recurOnDay(int $dayMask) : bool
Parameters
$dayMask : int

A mask consisting of Horde_Date::MASK_* constants specifying the day(s) to check.

Return values
bool

True if this event recurs on the given day(s).

reset()

Resets the class properties.

public reset() : mixed
Return values
mixed

setRecurCount()

Sets the number of recurrences of this event.

public setRecurCount(int $count) : mixed
Parameters
$count : int

The number of recurrences.

Return values
mixed

setRecurEnd()

Sets the end date of the recurrence interval.

public setRecurEnd(Horde_Date $end) : mixed
Parameters
$end : Horde_Date

The recurrence end.

Return values
mixed

setRecurInterval()

Sets the length of time between recurrences of this event.

public setRecurInterval(int $interval) : mixed
Parameters
$interval : int

The time between recurrences.

Return values
mixed

setRecurOnDay()

Specifies the days this event recurs on.

public setRecurOnDay(int $dayMask) : mixed
Parameters
$dayMask : int

A mask consisting of Horde_Date::MASK_* constants specifying the day(s) to recur on.

Return values
mixed

setRecurStart()

Sets the start date of the recurrence interval.

public setRecurStart(Horde_Date $start) : mixed
Parameters
$start : Horde_Date

The recurrence start.

Return values
mixed

setRecurType()

Sets a recurrence type for this event.

public setRecurType(int $recurrence) : mixed
Parameters
$recurrence : int

A RECUR_* constant.

Return values
mixed

toHash()

Returns a hash representing this object.

public toHash() : array<string|int, mixed>
Tags
since

Horde_Date 2.4.0

see
fromHash()
Return values
array<string|int, mixed>

A hash of this object.

toJson()

Returns a simple object suitable for json transport representing this object.

public toJson() : object

Possible properties are:

  • t: type
  • i: interval
  • e: end date
  • c: count
  • d: data
  • co: completions
  • ex: exceptions
Return values
object

A simple object.

toKolab()

Export this object into a Kolab hash.

public toKolab() : array<string|int, mixed>
Return values
array<string|int, mixed>

The recurrence hash.

toString()

Output a human readable description of the recurrence rule.

public toString(mixed $date_format[, mixed $time_format = '%X' ]) : string
Parameters
$date_format : mixed
$time_format : mixed = '%X'
Tags
since
2.1.0
Return values
string

_formatExceptionDate()

Returns a correcty formatted exception date for recurring events.

protected _formatExceptionDate(string $date, string $format) : string
Parameters
$date : string

Exception in the format Ymd.

$format : string

The format to display in.

Tags
since
2.1.0
Return values
string

The formatted date and delete link.

_nextDaily()

Finds the next daily recurrence of this event that's after $afterDate.

protected _nextDaily(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

_nextMonthlyDate()

Finds the next monthly recurrence on the same date of this event that's after $afterDate.

protected _nextMonthlyDate(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

_nextMonthlyWeekday()

Finds the next monthly recurrence on the same weekday of this event that's after $afterDate.

protected _nextMonthlyWeekday(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

_nextWeekly()

Finds the next weekly recurrence of this event that's after $afterDate.

protected _nextWeekly(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

_nextYearlyDate()

Finds the next yearly recurrence on the same date of this event that's after $afterDate.

protected _nextYearlyDate(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

_nextYearlyDay()

Finds the next yearly recurrence on the same day of the year of this event that's after $afterDate.

protected _nextYearlyDay(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

_nextYearlyWeekday()

Finds the next yearly recurrence on the same weekday of this event that's after $afterDate.

protected _nextYearlyWeekday(Horde_Date|string $after) : Horde_Date|bool
Parameters
$after : Horde_Date|string

Return events after this date.

Return values
Horde_Date|bool

The date of the next recurrence or false if the event does not recur after $afterDate.

Search results