You are here

function theme_date_all_day in Date 8

Same name and namespace in other branches
  1. 5.2 date/date.theme \theme_date_all_day()
  2. 6.2 date/date.theme \theme_date_all_day()
  3. 7.3 date_all_day/date_all_day.module \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 $field, the field definition for this date field.:

string $which, which value to return, 'date1' or 'date2' .:

object $date1, a date/time object for the 'start' date.:

object $date2, a date/time object for the 'end' date.:

string $format:

object $entity, the node this date comes from (may be incomplete, always contains nid).:

object $view, the view this node comes from, if applicable.:

Return value

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 102
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;
  $granularity = $field['settings']['granularity'];
  if (empty($date1) || !$date1 instanceof DrupalDateTime || $format == 'format_interval') {
    return;
  }
  if (empty($date2)) {
    $date2 = $date1;
  }
  $suffix = '';
  if (!DateGranularity::hasTime($granularity)) {
    $format = DateGranularity::limitFormat($format, DateGranularity::$date_parts);
  }
  else {
    $format_granularity = date_format_order($format);
    $format_has_time = FALSE;
    if (in_array('hour', $format_granularity)) {
      $format_has_time = TRUE;
    }
    $all_day = date_all_day_field($field, $instance, $date1, $date2);
    if ($all_day && $format_has_time) {
      $format = DateGranularity::limitFormat($format, DateGranularity::$date_parts);
      $suffix = ' ' . theme('date_all_day_label');
    }
  }
  return trim($which
    ->format($format) . $suffix);
}