function theme_date_display_combination in Date 6
Same name and namespace in other branches
- 8 date.theme \theme_date_display_combination()
- 5.2 date/date.theme \theme_date_display_combination()
- 5 date.module \theme_date_display_combination()
- 6.2 date/date.theme \theme_date_display_combination()
- 7.3 date.theme \theme_date_display_combination()
- 7 date.theme \theme_date_display_combination()
- 7.2 date.theme \theme_date_display_combination()
Theme from/to date combination in the view.
Useful values: $dates['format'] - the format string used on these dates $dates['value']['local']['object'] - the local date object for the From date $dates['value2']['local']['object'] - the local date object for the To date $dates['value']['local']['datetime'] - the datetime value of the From date database (GMT) value $dates['value2']['local']['datetime'] - the datetime value of the To date database (GMT) value $dates['value']['formatted'] = formatted From date, i.e. 'February 15, 2007 2:00 pm'; $dates['value']['formatted_date'] - only the date part of the formatted From date $dates['value']['formatted_time'] - only the time part of the formatted From date $dates['value2']['formatted'] = formatted To date, i.e. 'February 15, 2007 6:00 pm'; $dates['value2']['formatted_date'] - only the date part of the formatted To date $dates['value2']['formatted_time'] - only the time part of the formatted To date
1 string reference to 'theme_date_display_combination'
- date_theme in date/
date.module - Implementation of hook_theme().
File
- date/
date.theme, line 28 - Theme functions.
Code
function theme_date_display_combination($element) {
$dates = date_formatter_process($element);
$date1 = $dates['value']['formatted'];
$date2 = $dates['value2']['formatted'];
// Pull the timezone out of the formatted result and tack it
// back on at the end, if it is in the current formatted date.
$timezone = '';
if (!empty($element['#item']['timezone']) && strpos($date1, $element['#item']['timezone'])) {
$timezone = ' ' . $element['#item']['timezone'];
}
$date1 = str_replace($element['#item']['timezone'], '', $date1);
$date2 = str_replace($element['#item']['timezone'], '', $date2);
// No date values, display nothing.
$output = '';
if (empty($date1) && empty($date2)) {
$output .= '';
}
elseif ($date1 == $date2 || empty($date2)) {
$output .= '<span class="date-display-single">' . $date1 . $timezone . '</span>';
}
elseif ($dates['value']['formatted_date'] == $dates['value2']['formatted_date']) {
$output .= '<span class="date-display-single">' . $dates['value']['formatted_date'] . '</span> ' . '<span class="date-display-start">' . $dates['value']['formatted_time'] . '</span>' . '<span class="date-display-separator"> - </span>' . '<span class="date-display-end">' . $dates['value2']['formatted_time'] . $timezone . '</span>';
}
else {
$output .= '<span class="date-display-start">' . $date1 . '</span>' . '<span class="date-display-separator"> - </span>' . '<span class="date-display-end">' . $date2 . $timezone . '</span>';
}
if (module_exists('date_repeat') && !empty($item['rrule'])) {
include_once drupal_get_path('module', 'date') . '/date_repeat.inc';
$output .= theme('date_repeat_display', $field, $item, $node, $dates);
}
return $output;
}