You are here

function theme_date_all_day in Date 6.2

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. 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 from/to 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 'from' date.:

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

string $format:

object $node, 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.

1 theme call to theme_date_all_day()
date_formatter_process in date/date.module
Helper function for creating formatted date arrays from a formatter.

File

date/date.theme, line 246
Theme functions.

Code

function theme_date_all_day($field, $which, $date1, $date2, $format, $node, $view = NULL) {
  if (empty($date1) || !is_object($date1) || $format == 'format_interval') {
    return;
  }
  if (empty($date2)) {
    $date2 = $date1;
  }
  $suffix = '';
  if (!date_has_time($field['granularity'])) {
    $format = date_limit_format($format, array(
      'year',
      'month',
      'day',
    ));
  }
  else {
    $format_granularity = date_format_order($format);
    $format_has_time = FALSE;
    if (in_array('hour', $format_granularity)) {
      $format_has_time = TRUE;
    }
    $all_day = date_field_all_day($field, $date1, $date2);
    if ($all_day && $format_has_time) {
      $format = date_limit_format($format, array(
        'year',
        'month',
        'day',
      ));
      $suffix = ' ' . theme('date_all_day_label');
    }
  }
  return trim(date_format_date(${$which}, 'custom', $format) . $suffix);
}