You are here

function theme_date_all_day in Date 7.3

Same name and namespace in other branches
  1. 8 date_all_day/date_all_day.module \theme_date_all_day()
  2. 5.2 date/date.theme \theme_date_all_day()
  3. 6.2 date/date.theme \theme_date_all_day()
  4. 7 date.theme \theme_date_all_day()
  5. 7.2 date_all_day/date_all_day.module \theme_date_all_day()

Adjust start/end date format to account for 'all day' .

Parameters

array $vars: Contains the following items: 'field' - The field definition for this date field. 'which' - Which value to return, 'date1' or 'date2'. 'date1' - A date/time object for the 'start' date. 'date2' - A date/time object for the 'end' date. 'format' - A date/time format. 'entity' - The node this date comes from (may be incomplete, always contains nid). 'view' - The view this node comes from, if applicable.

Return value

string|null Formatted date.

2 theme calls to theme_date_all_day()
date_all_day_date_formatter_dates_alter in date_all_day/date_all_day.module
Implements hook_date_formatter_dates_alter().
hook_date_formatter_dates_alter in ./date.api.php
Alter the dates array created by date_formatter_process().

File

date_all_day/date_all_day.module, line 105
Adds All Day functionality to the Date field.

Code

function theme_date_all_day($vars) {
  $field = $vars['field'];
  $instance = $vars['instance'];
  $which = $vars['which'];
  $date1 = $vars['date1'];
  $date2 = $vars['date2'];
  $format = $vars['format'];
  $entity = $vars['entity'];
  $view = !empty($vars['view']) ? $vars['view'] : NULL;
  if (empty($date1) || !is_object($date1) || $format == 'format_interval') {
    return;
  }
  if (empty($date2)) {
    $date2 = $date1;
  }
  $suffix = '';
  if (date_has_time($field['settings']['granularity'])) {
    $format = date_limit_format($format, array(
      'year',
      'month',
      'day',
    ));
  }

  // Theme the all-day value.
  $suffix = ' ' . theme('date_all_day_label');
  return trim(date_format_date(${$which}, 'custom', $format) . $suffix);
}