You are here

function _fullcalendar_process_dates in FullCalendar 7.2

Process the dates, format them, and determine if it is all day.

Parameters

array $instance: The field instance.

object $entity: The entity object

array $field: The field info.

array $item: The date item.

Return value

array A numerically indexed array containing these elements:

  • 0: The start date object.
  • 1: The end date object.
  • 2: A Boolean representing whether the date is all day.
1 call to _fullcalendar_process_dates()
fullcalendar_prepare_events in theme/theme.inc
Build a render array representing the events.

File

theme/theme.inc, line 316
Preprocess functions for FullCalendar.

Code

function _fullcalendar_process_dates($instance, $entity, $field, $item) {
  if (isset($item['db']['value'])) {
    $date1 = $item['db']['value'];
    date_timezone_set($date1, timezone_open($item['timezone']));
    $date2 = $item['db']['value2'];
    date_timezone_set($date2, timezone_open($item['timezone']));
  }
  else {
    $date = date_formatter_process($instance['display']['default']['type'], $entity->entity_type, $entity, $field, $instance, LANGUAGE_NONE, $item, $instance['display']['default']);
    if (empty($date['value']['local']['object'])) {
      return;
    }
    $date1 = $date['value']['local']['object'];
    $date2 = $date['value2']['local']['object'];
  }

  // Allow modules to alter the date objects.
  $context = array(
    'instance' => $instance,
    'entity' => $entity,
    'field' => $field,
  );
  drupal_alter('fullcalendar_process_dates', $date1, $date2, $context);
  $start = $date1
    ->format(DATE_FORMAT_DATETIME);
  $end = $date2
    ->format(DATE_FORMAT_DATETIME);
  $all_day = _fullcalendar_date_all_day_field($field, $instance, $date1, $date2);
  return array(
    $start,
    $end,
    $all_day,
  );
}