You are here

function _fullcalendar_set_display_times in FullCalendar 6.2

Same name and namespace in other branches
  1. 6 fullcalendar.module \_fullcalendar_set_display_times()
  2. 7 fullcalendar.module \_fullcalendar_set_display_times()

Translates times to the right display times.

This is done by passing times through date modules date_formatter_process function.

Parameters

$node: The node that will be updated.

$field_name: The name of the date field.

$field: The field structure for the date field.

$item: The field value for the date field.

$index: The current index of the date field.

Return value

String containing specially formatted link for the FullCalendar plugin.

1 call to _fullcalendar_set_display_times()
template_preprocess_fullcalendar_fields in theme/theme.inc
Prepares variables for template file invoked for row type.

File

./fullcalendar.module, line 244
Provides a views style plugin for FullCalendar

Code

function _fullcalendar_set_display_times($node, $field_name, $field, $item, $index) {
  if (is_array($node->{$field_name})) {
    $dfp_info = array(
      '#node' => $node,
      '#field_name' => $field_name,
      '#formatter' => NULL,
      '#item' => $item,
    );
    $date = date_formatter_process($dfp_info);
    $date1 = $date['value']['local']['object'];
    $date2 = $date['value2']['local']['object'];
  }
  else {
    $date1 = date_make_date($node->{$field_name}, date_default_timezone(), DATE_UNIX);
    $date2 = $date1;
  }
  $attributes = array(
    'field' => $field_name,
    'allDay' => date_field_all_day($field, $date1, $date2),
    'start' => date_format($date1, DATE_FORMAT_DATETIME),
    'end' => date_format($date2, DATE_FORMAT_DATETIME),
    'index' => $index,
    'nid' => $node->nid,
    'cn' => $node->class,
    'title' => $node->title,
    'class' => 'fullcalendar-event-details',
    'editable' => $field['editable'],
  );
  $text = date_format_date($date1);
  if (!$attributes['allDay']) {
    $text .= ' to ' . date_format_date($date2);
  }
  return l($text, $node->url, array(
    'attributes' => $attributes,
  ));
}