\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.

Summary

Methods
Properties
Constants
__construct()
fromHash()
reset()
recurOnDay()
setRecurOnDay()
getRecurOnDays()
hasRecurType()
setRecurType()
getRecurType()
getRecurName()
setRecurInterval()
getRecurInterval()
setRecurCount()
getRecurCount()
hasRecurCount()
setRecurStart()
getRecurStart()
setRecurEnd()
getRecurEnd()
hasRecurEnd()
nextRecurrence()
hasActiveRecurrence()
nextActiveRecurrence()
addException()
deleteException()
hasException()
getExceptions()
addCompletion()
deleteCompletion()
hasCompletion()
getCompletions()
fromRRule10()
toRRule10()
fromRRule20()
toRRule20()
fromKolab()
toKolab()
toHash()
toJson()
toString()
isEqual()
$start
$recurEnd
$recurCount
$recurType
$recurInterval
$recurData
$exceptions
$completions
RECUR_NONE
RECUR_DAILY
RECUR_WEEKLY
RECUR_MONTHLY_DATE
RECUR_MONTHLY_WEEKDAY
RECUR_MONTHLY_LAST_WEEKDAY
RECUR_YEARLY_DATE
RECUR_YEARLY_DAY
RECUR_YEARLY_WEEKDAY
_nextDaily()
_nextWeekly()
_nextMonthlyDate()
_nextMonthlyWeekday()
_nextYearlyDate()
_nextYearlyDay()
_nextYearlyWeekday()
_formatExceptionDate()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

RECUR_NONE

RECUR_NONE

No Recurrence

RECUR_DAILY

RECUR_DAILY

Recurs daily.

RECUR_WEEKLY

RECUR_WEEKLY

Recurs weekly.

RECUR_MONTHLY_DATE

RECUR_MONTHLY_DATE

Recurs monthly on the same date.

RECUR_MONTHLY_WEEKDAY

RECUR_MONTHLY_WEEKDAY

Recurs monthly on the same week day.

RECUR_MONTHLY_LAST_WEEKDAY

RECUR_MONTHLY_LAST_WEEKDAY

Recurs monthly on the same last week day.

RECUR_YEARLY_DATE

RECUR_YEARLY_DATE

Recurs yearly on the same date.

RECUR_YEARLY_DAY

RECUR_YEARLY_DAY

Recurs yearly on the same day of the year.

RECUR_YEARLY_WEEKDAY

RECUR_YEARLY_WEEKDAY

Recurs yearly on the same week day.

Properties

$start

$start : \Horde_Date

The start time of the event.

Type

\Horde_Date

$recurEnd

$recurEnd : \Horde_Date

The end date of the recurrence interval.

Type

\Horde_Date

$recurCount

$recurCount : integer

The number of recurrences.

Type

integer

$recurType

$recurType : integer

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

Type

integer

$recurInterval

$recurInterval : integer

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

Type

integer

$recurData

$recurData : integer

Any additional recurrence data.

Type

integer

$exceptions

$exceptions : array

All the exceptions from recurrence for this event.

Type

array

$completions

$completions : array

All the dates this recurrence has been marked as completed.

Type

array

Methods

__construct()

__construct(\Horde_Date  $start) 

Constructor.

Parameters

\Horde_Date $start

Start of the recurring event.

fromHash()

fromHash(array  $hash) 

Creates an instance of this class from a hash.

Parameters

array $hash

A hash of this object.

reset()

reset() 

Resets the class properties.

recurOnDay()

recurOnDay(integer  $dayMask) : boolean

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

Parameters

integer $dayMask

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

Returns

boolean —

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

setRecurOnDay()

setRecurOnDay(integer  $dayMask) 

Specifies the days this event recurs on.

Parameters

integer $dayMask

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

getRecurOnDays()

getRecurOnDays() : integer

Returns the days this event recurs on.

Returns

integer —

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

hasRecurType()

hasRecurType(integer  $recurrence) : boolean

Returns whether this event has a specific recurrence type.

Parameters

integer $recurrence

RECUR_* constant of the recurrence type to check for.

Returns

boolean —

True if the event has the specified recurrence type.

setRecurType()

setRecurType(integer  $recurrence) 

Sets a recurrence type for this event.

Parameters

integer $recurrence

A RECUR_* constant.

getRecurType()

getRecurType() : integer

Returns recurrence type of this event.

Returns

integer —

A RECUR_* constant.

getRecurName()

getRecurName() : string

Returns a description of this event's recurring type.

Returns

string —

Human readable recurring type.

setRecurInterval()

setRecurInterval(integer  $interval) 

Sets the length of time between recurrences of this event.

Parameters

integer $interval

The time between recurrences.

getRecurInterval()

getRecurInterval() : integer

Retrieves the length of time between recurrences of this event.

Returns

integer —

The number of seconds between recurrences.

setRecurCount()

setRecurCount(integer  $count) 

Sets the number of recurrences of this event.

Parameters

integer $count

The number of recurrences.

getRecurCount()

getRecurCount() : integer

Retrieves the number of recurrences of this event.

Returns

integer —

The number recurrences.

hasRecurCount()

hasRecurCount() : boolean

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

Returns

boolean —

True if this recurrence has a fixed count.

setRecurStart()

setRecurStart(\Horde_Date  $start) 

Sets the start date of the recurrence interval.

Parameters

\Horde_Date $start

The recurrence start.

getRecurStart()

getRecurStart() : \Horde_Date

Retrieves the start date of the recurrence interval.

Returns

\Horde_Date

The recurrence start.

setRecurEnd()

setRecurEnd(\Horde_Date  $end) 

Sets the end date of the recurrence interval.

Parameters

\Horde_Date $end

The recurrence end.

getRecurEnd()

getRecurEnd() : \Horde_Date

Retrieves the end date of the recurrence interval.

Returns

\Horde_Date

The recurrence end.

hasRecurEnd()

hasRecurEnd() : boolean

Returns whether this event has a recurrence end.

Returns

boolean —

True if this recurrence ends.

nextRecurrence()

nextRecurrence(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

hasActiveRecurrence()

hasActiveRecurrence() : boolean

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

Returns

boolean —

True if an active recurrence exists.

nextActiveRecurrence()

nextActiveRecurrence(\Horde_Date  $afterDate) : \Horde_Date|boolean

Returns the next active recurrence.

Parameters

\Horde_Date $afterDate

Return events after this date.

Returns

\Horde_Date|boolean —

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

addException()

addException(integer  $year, integer  $month, integer  $mday) 

Adds an exception to a recurring event.

Parameters

integer $year

The year of the exception.

integer $month

The month of the exception.

integer $mday

The day of the month of the exception.

deleteException()

deleteException(integer  $year, integer  $month, integer  $mday) 

Deletes an exception from a recurring event.

Parameters

integer $year

The year of the exception.

integer $month

The month of the exception.

integer $mday

The day of the month of the exception.

hasException()

hasException(integer  $year, integer  $month, integer  $mday) : boolean

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

Parameters

integer $year

The year of the reucrance.

integer $month

The month of the reucrance.

integer $mday

The day of the month of the reucrance.

Returns

boolean —

True if an exception exists for the given date.

getExceptions()

getExceptions() : array

Retrieves all the exceptions for this event.

Returns

array —

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

addCompletion()

addCompletion(integer  $year, integer  $month, integer  $mday) 

Adds a completion to a recurring event.

Parameters

integer $year

The year of the exception.

integer $month

The month of the exception.

integer $mday

The day of the month of the completion.

deleteCompletion()

deleteCompletion(integer  $year, integer  $month, integer  $mday) 

Deletes a completion from a recurring event.

Parameters

integer $year

The year of the exception.

integer $month

The month of the exception.

integer $mday

The day of the month of the completion.

hasCompletion()

hasCompletion(integer  $year, integer  $month, integer  $mday) : boolean

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

Parameters

integer $year

The year of the recurrance.

integer $month

The month of the recurrance.

integer $mday

The day of the month of the recurrance.

Returns

boolean —

True if a completion exists for the given date.

getCompletions()

getCompletions() : array

Retrieves all the completions for this event.

Returns

array —

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

fromRRule10()

fromRRule10(string  $rrule) 

Parses a vCalendar 1.0 recurrence rule.

Parameters

string $rrule

A vCalendar 1.0 conform RRULE value.

toRRule10()

toRRule10(\Horde_Icalendar  $calendar) : string

Creates a vCalendar 1.0 recurrence rule.

Parameters

\Horde_Icalendar $calendar

A Horde_Icalendar object instance.

Returns

string —

A vCalendar 1.0 conform RRULE value.

fromRRule20()

fromRRule20(string  $rrule) 

Parses an iCalendar 2.0 recurrence rule.

Parameters

string $rrule

An iCalendar 2.0 conform RRULE value.

toRRule20()

toRRule20(\Horde_Icalendar  $calendar) : string

Creates an iCalendar 2.0 recurrence rule.

Parameters

\Horde_Icalendar $calendar

A Horde_Icalendar object instance.

Returns

string —

An iCalendar 2.0 conform RRULE value.

fromKolab()

fromKolab(array  $hash) : boolean

Parses the recurrence data from a Kolab hash.

Parameters

array $hash

The hash to convert.

Returns

boolean —

True if the hash seemed valid, false otherwise.

toKolab()

toKolab() : array

Export this object into a Kolab hash.

Returns

array —

The recurrence hash.

toHash()

toHash() : array

Returns a hash representing this object.

Returns

array —

A hash of this object.

toJson()

toJson() : object

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

Possible properties are:

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

Returns

object —

A simple object.

toString()

toString(  $date_format,   $time_format = '%X') : string

Output a human readable description of the recurrence rule.

Parameters

$date_format
$time_format

Returns

string

isEqual()

isEqual(\Horde_Date_Recurrence  $recurrence) : boolean

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

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

Parameters

\Horde_Date_Recurrence $recurrence

The recurrence object to check equality to.

Returns

boolean —

True if the recurrence rules are the same.

_nextDaily()

_nextDaily(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

_nextWeekly()

_nextWeekly(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

_nextMonthlyDate()

_nextMonthlyDate(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

_nextMonthlyWeekday()

_nextMonthlyWeekday(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

_nextYearlyDate()

_nextYearlyDate(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

_nextYearlyDay()

_nextYearlyDay(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

_nextYearlyWeekday()

_nextYearlyWeekday(\Horde_Date|string  $after) : \Horde_Date|boolean

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

Parameters

\Horde_Date|string $after

Return events after this date.

Returns

\Horde_Date|boolean —

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

_formatExceptionDate()

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

Returns a correcty formatted exception date for recurring events.

Parameters

string $date

Exception in the format Ymd.

string $format

The format to display in.

Returns

string —

The formatted date and delete link.