PHP Class Recurr\Rule

http://www.ietf.org/rfc/rfc2445.txt Information, not contained in the built/parsed RRULE, necessary to determine the various recurrence instance start time and dates are derived from the DTSTART property (default: \DateTime()). For example, "FREQ=YEARLY;BYMONTH=1" doesn't specify a specific day within the month or a time. This information would be the same as what is specified for DTSTART. BYxxx rule parts modify the recurrence in some manner. BYxxx rule parts for a period of time which is the same or greater than the frequency generally reduce or limit the number of occurrences of the recurrence generated. For example, "FREQ=DAILY;BYMONTH=1" reduces the number of recurrence instances from all days (if BYMONTH tag is not present) to all days in January. BYxxx rule parts for a period of time less than the frequency generally increase or expand the number of occurrences of the recurrence. For example, "FREQ=YEARLY;BYMONTH=1,2" increases the number of days within the yearly recurrence set from 1 (if BYMONTH tag is not present) to 2. If multiple BYxxx rule parts are specified, then after evaluating the specified FREQ and INTERVAL rule parts, the BYxxx rule parts are applied to the current set of evaluated occurrences in the following order: BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS; then COUNT and UNTIL are evaluated. Here is an example of evaluating multiple BYxxx rule parts. FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30 First, the "INTERVAL=2" would be applied to "FREQ=YEARLY" to arrive at "every other year". Then, "BYMONTH=1" would be applied to arrive at "every January, every other year". Then, "BYDAY=SU" would be applied to arrive at "every Sunday in January, every other year". Then, "BYHOUR=8,9" would be applied to arrive at "every Sunday in January at 8 AM and 9 AM, every other year". Then, "BYMINUTE=30" would be applied to arrive at "every Sunday in January at 8:30 AM and 9:30 AM, every other year". Then, lacking information from RRULE, the second is derived from DTSTART, to end up in "every Sunday in January at 8:30:00 AM and 9:30:00 AM, every other year". Similarly, if the BYMINUTE, BYHOUR, BYDAY, BYMONTHDAY or BYMONTH rule part were missing, the appropriate minute, hour, day or month would have been retrieved from the "DTSTART" property. Example: The following is a rule which specifies 10 meetings which occur every other day: FREQ=DAILY;COUNT=10;INTERVAL=2
Author: Shaun Simmons ([email protected])
Mostrar archivo Open project: simshaun/recurr Class Usage Examples

Public Properties

Property Type Description
$freqs

Protected Properties

Property Type Description
$byDay array
$byHour array
$byMinute array
$byMonth array
$byMonthDay array
$bySecond array
$bySetPosition integer
$byWeekNumber array
$byYearDay array
$count integer | null
$days array
$endDate DateTime | null
$exDates array
$freq string
$interval integer
$isExplicitInterval boolean
$isStartDateFromDtstart boolean
$rDates array
$startDate DateTime | null
$timezone string
$until DateTime | null
$weekStart string
$weekStartDefined

Public Methods

Method Description
__construct ( string $rrule = null, string | DateTime $startDate = null, DateTime | null $endDate = null, string $timezone = null ) Construct a new Rule.
createFromArray ( array $rrule, string | DateTime $startDate = null, DateTime | null $endDate = null, string $timezone = null ) : Rule Create a Rule object based on a RRULE array.
createFromString ( string $rrule, string | DateTime $startDate = null, DateTime | null $endDate = null, string $timezone = null ) : Rule Create a Rule object based on a RRULE string.
getByDay ( ) : array Get an array of days of the week (SU, MO, TU, .
getByDayTransformedToWeekdays ( ) : array Get an array of Weekdays
getByHour ( ) : array Get an array of hours of the day.
getByMinute ( ) : array Get an array of minutes within an hour.
getByMonth ( ) : array Get an array of months of the year.
getByMonthDay ( ) : array Get an array of days of the month.
getBySecond ( ) : array Get an array of seconds within a minute.
getBySetPosition ( ) : array Get the array of values which corresponds to the nth occurrence within the set of events specified by the rule.
getByWeekNumber ( ) : array Get an array of ordinals specifying weeks of the year.
getByYearDay ( ) : array Get an array of days of the year.
getCount ( ) : integer | null Get the number of occurrences at which the recurrence is range-bound.
getEndDate ( ) : DateTime
getExDates ( ) : recurr\DateExclusion[] Get the array of dates that will not be included in a recurrence set.
getFreq ( ) : integer Get the type of recurrence rule (as integer).
getFreqAsText ( ) : string Get the type of recurrence rule (as text).
getInterval ( ) : integer Get the interval that represents how often the recurrence rule repeats.
getRDates ( ) : recurr\DateInclusion[] Get the array of dates that will be included in a recurrence set.
getStartDate ( ) : DateTime
getString ( $timezoneType = self::TZ_FLOAT ) : string Get the RRULE as a string
getTimezone ( ) : null | string Get timezone to use for \DateTime() objects that are UTC.
getUntil ( ) : DateTime | null Get the \DateTime that the recurrence lasts until.
getWeekStart ( ) : string Get the day on which the workweek starts.
getWeekStartAsNum ( ) : integer Get the day on which the workweek starts, as an integer from 0-6, 0 being Monday and 6 being Sunday.
hasByMonth ( )
loadFromArray ( $parts ) : Rule Populate the object based on a RRULE array.
loadFromString ( string $rrule ) : Rule Populate the object based on a RRULE string.
setByDay ( array $byDay ) This rule specifies an array of days of the week;
setByHour ( array $byHour ) This rule specifies an array of hours of the day.
setByMinute ( array $byMinute ) This rule specifies an array of minutes within an hour.
setByMonth ( array $byMonth ) This rule specifies an array of months of the year.
setByMonthDay ( array $byMonthDay ) This rule specifies an array of days of the month.
setBySecond ( array $bySecond ) This rule specifies an array of seconds within a minute.
setBySetPosition ( array $bySetPosition ) This rule specifies an array of values which corresponds to the nth occurrence within the set of events specified by the rule. Valid values are 1 to 366 or -366 to -1. It MUST only be used in conjunction with another BYxxx rule part.
setByWeekNumber ( array $byWeekNumber ) This rule specifies an array of ordinals specifying weeks of the year.
setByYearDay ( array $byYearDay ) This rule specifies an array of days of the year.
setCount ( integer $count ) The count defines the number of occurrences at which to range-bound the recurrence. The DTSTART counts as the first occurrence.
setEndDate ( DateTime | null $endDate ) This date specifies the last possible instance in the recurrence set.
setExDates ( array $exDates ) This rule specifies an array of exception dates that will not be included in a recurrence set.
setFreq ( string $freq ) Identifies the type of recurrence rule.
setInterval ( integer $interval ) The interval represents how often the recurrence rule repeats.
setRDates ( array $rDates ) This rule specifies an array of dates that will be included in a recurrence set.
setStartDate ( DateTime | null $startDate, boolean | null $includeInString = null ) This date specifies the first instance in the recurrence set.
setTimezone ( string $timezone )
setUntil ( DateTime $until ) Define a \DateTime value which bounds the recurrence rule in an inclusive manner. If the value specified is synchronized with the specified recurrence, this DateTime becomes the last instance of the recurrence. If not present, and a COUNT is also not present, the RRULE is considered to repeat forever.
setWeekStart ( string $weekStart ) This rule specifies the day on which the workweek starts.

Private Methods

Method Description
convertZtoUtc ( DateTime $date ) : DateTime DateTime::setTimezone fails if the timezone does not have an ID.

Method Details

__construct() public method

Construct a new Rule.
public __construct ( string $rrule = null, string | DateTime $startDate = null, DateTime | null $endDate = null, string $timezone = null )
$rrule string RRULE string
$startDate string | DateTime
$endDate DateTime | null
$timezone string

createFromArray() public static method

Create a Rule object based on a RRULE array.
public static createFromArray ( array $rrule, string | DateTime $startDate = null, DateTime | null $endDate = null, string $timezone = null ) : Rule
$rrule array RRULE array
$startDate string | DateTime
$endDate DateTime | null
$timezone string
return Rule

createFromString() public static method

Create a Rule object based on a RRULE string.
public static createFromString ( string $rrule, string | DateTime $startDate = null, DateTime | null $endDate = null, string $timezone = null ) : Rule
$rrule string RRULE string
$startDate string | DateTime
$endDate DateTime | null
$timezone string
return Rule

getByDay() public method

.)
public getByDay ( ) : array
return array

getByDayTransformedToWeekdays() public method

Get an array of Weekdays
public getByDayTransformedToWeekdays ( ) : array
return array of Weekdays

getByHour() public method

Get an array of hours of the day.
public getByHour ( ) : array
return array

getByMinute() public method

Get an array of minutes within an hour.
public getByMinute ( ) : array
return array

getByMonth() public method

Get an array of months of the year.
public getByMonth ( ) : array
return array

getByMonthDay() public method

Get an array of days of the month.
public getByMonthDay ( ) : array
return array

getBySecond() public method

Get an array of seconds within a minute.
public getBySecond ( ) : array
return array

getBySetPosition() public method

Get the array of values which corresponds to the nth occurrence within the set of events specified by the rule.
public getBySetPosition ( ) : array
return array

getByWeekNumber() public method

Get an array of ordinals specifying weeks of the year.
public getByWeekNumber ( ) : array
return array

getByYearDay() public method

Get an array of days of the year.
public getByYearDay ( ) : array
return array

getCount() public method

Get the number of occurrences at which the recurrence is range-bound.
public getCount ( ) : integer | null
return integer | null

getEndDate() public method

public getEndDate ( ) : DateTime
return DateTime

getExDates() public method

Get the array of dates that will not be included in a recurrence set.
public getExDates ( ) : recurr\DateExclusion[]
return recurr\DateExclusion[]

getFreq() public method

Get the type of recurrence rule (as integer).
public getFreq ( ) : integer
return integer

getFreqAsText() public method

Get the type of recurrence rule (as text).
public getFreqAsText ( ) : string
return string

getInterval() public method

Get the interval that represents how often the recurrence rule repeats.
public getInterval ( ) : integer
return integer

getRDates() public method

Get the array of dates that will be included in a recurrence set.
public getRDates ( ) : recurr\DateInclusion[]
return recurr\DateInclusion[]

getStartDate() public method

public getStartDate ( ) : DateTime
return DateTime

getString() public method

Get the RRULE as a string
public getString ( $timezoneType = self::TZ_FLOAT ) : string
return string

getTimezone() public method

Get timezone to use for \DateTime() objects that are UTC.
public getTimezone ( ) : null | string
return null | string

getUntil() public method

Get the \DateTime that the recurrence lasts until.
public getUntil ( ) : DateTime | null
return DateTime | null

getWeekStart() public method

Get the day on which the workweek starts.
public getWeekStart ( ) : string
return string

getWeekStartAsNum() public method

Get the day on which the workweek starts, as an integer from 0-6, 0 being Monday and 6 being Sunday.
public getWeekStartAsNum ( ) : integer
return integer

hasByMonth() public method

public hasByMonth ( )

loadFromArray() public method

Populate the object based on a RRULE array.
public loadFromArray ( $parts ) : Rule
return Rule

loadFromString() public method

Populate the object based on a RRULE string.
public loadFromString ( string $rrule ) : Rule
$rrule string RRULE string
return Rule

setByDay() public method

MO indicates Monday; TU indicates Tuesday; WE indicates Wednesday; TH indicates Thursday; FR indicates Friday; SA indicates Saturday; SU indicates Sunday. Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of the specific day within the MONTHLY or YEARLY RRULE. For example, within a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday within the month, whereas -1MO represents the last Monday of the month. If an integer modifier is not present, it means all days of this type within the specified frequency. For example, within a MONTHLY rule, MO represents all Mondays within the month. ------------------------------------------- DO NOT MIX DAYS AND DAYS WITH MODIFIERS. This is not supported. -------------------------------------------
public setByDay ( array $byDay )
$byDay array Array of days of the week

setByHour() public method

Valid values are 0 to 23.
public setByHour ( array $byHour )
$byHour array Array of hours of the day

setByMinute() public method

Valid values are 0 to 59.
public setByMinute ( array $byMinute )
$byMinute array Array of minutes within an hour

setByMonth() public method

Valid values are 1 to 12.
public setByMonth ( array $byMonth )
$byMonth array Array of months of the year from 1 to 12

setByMonthDay() public method

Valid values are 1 to 31 or -31 to -1. For example, -10 represents the tenth to the last day of the month.
public setByMonthDay ( array $byMonthDay )
$byMonthDay array Array of days of the month from -31 to 31

setBySecond() public method

Valid values are 0 to 59.
public setBySecond ( array $bySecond )
$bySecond array Array of seconds within a minute

setBySetPosition() public method

For example "the last work day of the month" could be represented as: RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 Each BYSETPOS value can include a positive or negative integer. If present, this indicates the nth occurrence of the specific occurrence within the set of events specified by the rule.
public setBySetPosition ( array $bySetPosition )
$bySetPosition array Array of values which corresponds to the nth occurrence within the set of events specified by the rule.

setByWeekNumber() public method

Valid values are 1 to 53 or -53 to -1. This corresponds to weeks according to week numbering as defined in [ISO 8601]. A week is defined as a seven day period, starting on the day of the week defined to be the week start (see setWeekStart). Week number one of the calendar year is the first week which contains at least four days in that calendar year. This rule is only valid for YEARLY rules. For example, 3 represents the third week of the year. Note: Assuming a Monday week start, week 53 can only occur when Thursday is January 1 or if it is a leap year and Wednesday is January 1.
public setByWeekNumber ( array $byWeekNumber )
$byWeekNumber array Array of ordinals specifying weeks of the year.

setByYearDay() public method

Valid values are 1 to 366 or -366 to -1. For example, -1 represents the last day of the year (December 31st) and -306 represents the 306th to the last day of the year (March 1st).
public setByYearDay ( array $byYearDay )
$byYearDay array Array of days of the year from -1 to 306

setCount() public method

Either COUNT or UNTIL may be specified, but COUNT and UNTIL MUST NOT both be specified.
public setCount ( integer $count )
$count integer Number of occurrences

setEndDate() public method

This date specifies the last possible instance in the recurrence set.
public setEndDate ( DateTime | null $endDate )
$endDate DateTime | null Date of the last possible instance in the recurrence

setExDates() public method

This rule specifies an array of exception dates that will not be included in a recurrence set.
public setExDates ( array $exDates )
$exDates array Array of dates that will not be included in the recurrence set.

setFreq() public method

May be one of: - Frequency::SECONDLY to specify repeating events based on an interval of a second or more. - Frequency::MINUTELY to specify repeating events based on an interval of a minute or more. - Frequency::HOURLY to specify repeating events based on an interval of an hour or more. - Frequency::DAILY to specify repeating events based on an interval of a day or more. - Frequency::WEEKLY to specify repeating events based on an interval of a week or more. - Frequency::MONTHLY to specify repeating events based on an interval of a month or more. - Frequency::YEAR to specify repeating events based on an interval of a year or more.
public setFreq ( string $freq )
$freq string Frequency of recurrence.

setInterval() public method

The default value is "1", meaning every second for a SECONDLY rule, or every minute for a MINUTELY rule, every hour for an HOURLY rule, every day for a DAILY rule, every week for a WEEKLY rule, every month for a MONTHLY rule and every year for a YEARLY rule.
public setInterval ( integer $interval )
$interval integer Positive integer that represents how often the recurrence rule repeats.

setRDates() public method

This rule specifies an array of dates that will be included in a recurrence set.
public setRDates ( array $rDates )
$rDates array Array of dates that will be included in the recurrence set.

setStartDate() public method

This date specifies the first instance in the recurrence set.
public setStartDate ( DateTime | null $startDate, boolean | null $includeInString = null )
$startDate DateTime | null Date of the first instance in the recurrence
$includeInString boolean | null If true, include as DTSTART when calling getString()

setTimezone() public method

See also: http://www.php.net/manual/en/timezones.php
public setTimezone ( string $timezone )
$timezone string

setUntil() public method

Either UNTIL or COUNT may be specified, but UNTIL and COUNT MUST NOT both be specified.
public setUntil ( DateTime $until )
$until DateTime The upper bound of the recurrence.

setWeekStart() public method

Valid values are MO, TU, WE, TH, FR, SA and SU. This is significant when a WEEKLY RRULE has an interval greater than 1, and a BYDAY rule part is specified. This is also significant when in a YEARLY RRULE when a BYWEEKNO rule is specified. The default value is MO.
public setWeekStart ( string $weekStart )
$weekStart string The day on which the workweek starts.

Property Details

$byDay protected_oe property

protected array $byDay
return array

$byHour protected_oe property

protected array $byHour
return array

$byMinute protected_oe property

protected array $byMinute
return array

$byMonth protected_oe property

protected array $byMonth
return array

$byMonthDay protected_oe property

protected array $byMonthDay
return array

$bySecond protected_oe property

protected array $bySecond
return array

$bySetPosition protected_oe property

protected int $bySetPosition
return integer

$byWeekNumber protected_oe property

protected array $byWeekNumber
return array

$byYearDay protected_oe property

protected array $byYearDay
return array

$count protected_oe property

protected int|null $count
return integer | null

$days protected_oe property

protected array $days
return array

$endDate protected_oe property

protected DateTime|null $endDate
return DateTime | null

$exDates protected_oe property

protected array $exDates
return array

$freq protected_oe property

protected string $freq
return string

$freqs public_oe static_oe property

public static $freqs

$interval protected_oe property

protected int $interval
return integer

$isExplicitInterval protected_oe property

protected bool $isExplicitInterval
return boolean

$isStartDateFromDtstart protected_oe property

protected bool $isStartDateFromDtstart
return boolean

$rDates protected_oe property

protected array $rDates
return array

$startDate protected_oe property

protected DateTime|null $startDate
return DateTime | null

$timezone protected_oe property

protected string $timezone
return string

$until protected_oe property

protected DateTime|null $until
return DateTime | null

$weekStart protected_oe property

protected string $weekStart
return string

$weekStartDefined protected_oe property

protected $weekStartDefined