You are here

protected function DateRecurDefaultRSet::_fixDates in Recurring Dates Field 8

2 calls to DateRecurDefaultRSet::_fixDates()
DateRecurDefaultRSet::addDate in src/DateRecurDefaultRSet.php
DateRecurDefaultRSet::addExDate in src/DateRecurDefaultRSet.php

File

src/DateRecurDefaultRSet.php, line 58

Class

DateRecurDefaultRSet

Namespace

Drupal\date_recur

Code

protected function _fixDates($datestr) {
  if (is_string($datestr) && strpos($datestr, ',')) {
    $dates = explode(',', $datestr);
  }
  else {
    $dates = [
      $datestr,
    ];
  }

  /** @var \DateTime $dtstart */
  $dtstart = $this
    ->getStartDate();
  foreach ($dates as $key => $datestr) {
    $date = RRule::parseDate($datestr);
    if ($dtstart) {
      $date
        ->setTimezone($dtstart
        ->getTimezone());
      $date
        ->setTime($dtstart
        ->format('H'), $dtstart
        ->format('i'));
    }
    $dates[$key] = $date;
  }
  return $dates;
}