public function DateRecurRRule::__construct in Recurring Dates Field 8
Parameters
string $rrule The repeat rule.:
\DateTime|DrupalDateTime $startDate The start date (DTSTART).:
\DateTime|DrupalDateTime|NULL $startDateEnd Optionally, the initial event's end date.:
Throws
\InvalidArgumentException
File
- src/
DateRecurRRule.php, line 78
Class
Namespace
Drupal\date_recurCode
public function __construct($rrule, $startDate, $startDateEnd = NULL, $timezone = NULL) {
$this->originalRuleString = $rrule;
$this->startDate = $startDate;
$this->recurTime = $this->startDate
->format('H:i');
if (empty($startDateEnd)) {
$startDateEnd = clone $startDate;
}
$this->startDateEnd = $startDateEnd;
$this->recurDiff = $this->startDate
->diff($startDateEnd);
$this::parseRrule($rrule, $startDate);
$this->rrule = new DateRecurDefaultRSet();
$this->rrule
->addRRule(new DateRecurDefaultRRule($this->parts));
if (!empty($this->setParts)) {
foreach ($this->setParts as $type => $type_parts) {
foreach ($type_parts as $part) {
list(, $part) = explode(':', $part);
switch ($type) {
case 'RDATE':
$this->rrule
->addDate($part);
break;
case 'EXDATE':
$this->rrule
->addExDate($part);
break;
case 'EXRULE':
$this->rrule
->addExRule($part);
}
}
}
}
if ($timezone) {
$this->timezone = $timezone;
$start = clone $this->startDate;
$start
->setTimezone(new \DateTimeZone($this->timezone));
$this->timezoneOffset = $start
->getOffset();
$this->rrule
->setTimezoneOffset($this->timezoneOffset);
}
}