protected function DateRRuleCalc::add_current_day in Date 8
Helper function to add current date to the $dates array.
Check that the date to be added is between the start and end date and that it is not in the $this->exceptions, nor already in the $this->result array, and that it meets other criteria in the RRULE.
4 calls to DateRRuleCalc::add_current_day()
- DateRRuleCalc::get_absolute_bydays in date_repeat/
lib/ Drupal/ date_repeat/ DateRRuleCalc.php - Get values for absolute BYDAYs.
- DateRRuleCalc::get_bymonthday_results in date_repeat/
lib/ Drupal/ date_repeat/ DateRRuleCalc.php - Processing for BYMONTHDAY values.
- DateRRuleCalc::get_other_results in date_repeat/
lib/ Drupal/ date_repeat/ DateRRuleCalc.php - Processing other than BYDAY or BYMONTHDAY.
- DateRRuleCalc::get_relative_bydays in date_repeat/
lib/ Drupal/ date_repeat/ DateRRuleCalc.php - Get results for relative BYDAY values.
File
- date_repeat/
lib/ Drupal/ date_repeat/ DateRRuleCalc.php, line 628 - Code to compute the dates that match an iCal RRULE.
Class
Namespace
Drupal\date_repeatCode
protected function add_current_day() {
if (!empty($this->max_count) && sizeof($this->result) >= $this->max_count) {
return FALSE;
}
if (!empty($this->end_date) && $this->current_day > $this->end_date) {
return FALSE;
}
if ($this->current_day < $this->start_date) {
return FALSE;
}
if (in_array($this->current_day
->format('Y-m-d'), $this->exceptions)) {
return FALSE;
}
if (!empty($this->rrule['BYDAY'])) {
$BYDAYS = $this->rrule['BYDAY'];
foreach ($BYDAYS as $delta => $BYDAY) {
$BYDAYS[$delta] = substr($BYDAY, -2);
}
if (!in_array(date_repeat_dow2day($this->current_day
->format('w')), $BYDAYS)) {
return FALSE;
}
}
if (!empty($this->rrule['BYYEAR']) && !in_array($this->current_day
->format('Y'), $this->rrule['BYYEAR'])) {
return FALSE;
}
if (!empty($this->rrule['BYMONTH']) && !in_array($this->current_day
->format('n'), $this->rrule['BYMONTH'])) {
return FALSE;
}
if (!empty($this->rrule['BYMONTHDAY'])) {
// Test month days, but only if there are no negative numbers.
$test = TRUE;
$BYMONTHDAYS = array();
foreach ($this->rrule['BYMONTHDAY'] as $day) {
if ($day > 0) {
$BYMONTHDAYS[] = $day;
}
else {
$test = FALSE;
break;
}
}
if ($test && !empty($BYMONTHDAYS) && !in_array($this->current_day
->format('j'), $BYMONTHDAYS)) {
return FALSE;
}
}
// Don't add a day if it is already saved so we don't throw the count off.
$formatted = $this->current_day
->format($this->default_format);
if (in_array($formatted, $this->result)) {
return TRUE;
}
else {
$this->result[] = $formatted;
}
}