You are here

protected function FullCalendarController::calculateEndDateFromDuration in Smart Date 3.1.x

Same name and namespace in other branches
  1. 8.2 src/Controller/FullCalendarController.php \Drupal\smart_date\Controller\FullCalendarController::calculateEndDateFromDuration()
  2. 3.x src/Controller/FullCalendarController.php \Drupal\smart_date\Controller\FullCalendarController::calculateEndDateFromDuration()
  3. 3.0.x src/Controller/FullCalendarController.php \Drupal\smart_date\Controller\FullCalendarController::calculateEndDateFromDuration()
  4. 3.2.x src/Controller/FullCalendarController.php \Drupal\smart_date\Controller\FullCalendarController::calculateEndDateFromDuration()
  5. 3.3.x src/Controller/FullCalendarController.php \Drupal\smart_date\Controller\FullCalendarController::calculateEndDateFromDuration()
  6. 3.4.x src/Controller/FullCalendarController.php \Drupal\smart_date\Controller\FullCalendarController::calculateEndDateFromDuration()

Calculating for switch between all day and regular events.

Parameters

int $duration: Duration in minutes.

string|null $endDate: End value to populate.

string $startDate: Start value of the date.

1 call to FullCalendarController::calculateEndDateFromDuration()
FullCalendarController::updateEvent in src/Controller/FullCalendarController.php
Update the event entity based on information passed in request.

File

src/Controller/FullCalendarController.php, line 171

Class

FullCalendarController
Calendar Event Controller, overridden to handle Smart Date events.

Namespace

Drupal\smart_date\Controller

Code

protected function calculateEndDateFromDuration(int &$duration, ?string &$endDate, string $startDate) {
  if ($duration % 1440 == '1439') {

    // This means an allday event is to become a regular event.
    if (empty($endDate)) {
      $endDate = strtotime($startDate) + $this->defaultTimedEventDuration;
      $duration = $this->defaultTimedEventDuration / 60;
    }
    else {
      $endDate = strtotime($endDate) + 1439 * 60;
    }
  }
  else {

    // This means an regular event is to become an allday event.
    if (empty($endDate)) {

      // If https://fullcalendar.io/docs/defaultAllDayEventDuration = 1 day.
      $endDate = strtotime($startDate) + 1439 * 60;
      $duration = 1439;
    }
    else {
      $endDate = strtotime($endDate);
    }
  }
}