protected function DateRRuleCalc::complete_rrule in Date 8
See if the RRULE needs some imputed values added to it.
1 call to DateRRuleCalc::complete_rrule()
- DateRRuleCalc::compute in date_repeat/
lib/ Drupal/ date_repeat/ DateRRuleCalc.php
File
- date_repeat/
lib/ Drupal/ date_repeat/ DateRRuleCalc.php, line 588 - Code to compute the dates that match an iCal RRULE.
Class
Namespace
Drupal\date_repeatCode
protected function complete_rrule() {
// If this is not a valid value, do nothing;
if (empty($this->rrule) || empty($this->rrule['FREQ'])) {
return FALSE;
}
// RFC 2445 says if no day or monthday is specified when creating repeats
// for weeks, months, or years, impute the value from the start date.
if (empty($this->rrule['BYDAY']) && $this->rrule['FREQ'] == 'WEEKLY') {
$this->rrule['BYDAY'] = array(
date_repeat_dow2day($this->start_date
->format('w')),
);
}
elseif (empty($this->rrule['BYDAY']) && empty($this->rrule['BYMONTHDAY']) && $this->rrule['FREQ'] == 'MONTHLY') {
$this->rrule['BYMONTHDAY'] = array(
$this->start_date
->format('j'),
);
}
elseif (empty($this->rrule['BYDAY']) && empty($this->rrule['BYMONTHDAY']) && empty($this->rrule['BYYEARDAY']) && $this->rrule['FREQ'] == 'YEARLY') {
$this->rrule['BYMONTHDAY'] = array(
$this->start_date
->format('j'),
);
if (empty($this->rrule['BYMONTH'])) {
$this->rrule['BYMONTH'] = array(
$this->start_date
->format('n'),
);
}
}
elseif (!empty($this->rrule['BYDAY']) && !in_array($this->rrule['FREQ'], array(
'MONTHLY',
'YEARLY',
))) {
foreach ($this->rrule['BYDAY'] as $delta => $BYDAY) {
$this->rrule['BYDAY'][$delta] = substr($BYDAY, -2);
}
}
}