function theme_date_display_combination in Date 5.2
Same name and namespace in other branches
- 8 date.theme \theme_date_display_combination()
- 5 date.module \theme_date_display_combination()
- 6.2 date/date.theme \theme_date_display_combination()
- 6 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.
Parameters
$field = the field settings:
$node = node information, this is not always available and not: always the full node, it depends on what value was provided to the formatter. Only the nid is always guaranteed to be available.
$dates - an array of date information, see explanation for date_field_object() for details.:
Useful values: $field['type_name'] is the content type $field['type'] is the field type
$node->nid is the node nid, get other node values using node_load($node->nid)
$node->date_id If set, this will show only an individual date on a field with multiple dates. The value should be a string that contains the following values, separated with colons:
- module name of the module adding the item
- node nid
- field name
- delta value of the field to be displayed
- other information the module's custom theme might need
Used by the calendar module and available for other uses. example: 'date:217:field_date:3:test'
$node->date_repeat_show If true, tells the theme to show all the computed values of a repeating date. If not true or not set, only the start date and the repeat rule will be displayed.
$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 theme call to theme_date_display_combination()
- date_field_formatter in date/
date.module - Implementation of hook_field_formatter().
File
- date/
date.theme, line 57 - Theme functions.
Code
function theme_date_display_combination($field, $item, $dates, $node = NULL) {
$date1 = $dates['value']['formatted'];
if (isset($dates['value2'])) {
$date2 = $dates['value2']['formatted'];
}
else {
$date2 = $date1;
}
// Pull the timezone, if any, out of the formatted result and tack it
// back on at the end, if it is in the current formatted date.
$timezone = $dates['value']['formatted_timezone'];
if ($timezone) {
$timezone = ' ' . $timezone;
}
$date1 = str_replace($timezone, '', $date1);
$date2 = str_replace($timezone, '', $date2);
// No date values, display nothing.
if (empty($date1) && empty($date2)) {
$output .= '';
}
elseif ($date1 == $date2 || empty($date2)) {
$output .= theme('date_display_single', $date1, $timezone);
}
elseif (date_has_time($field['granularity']) && $dates['value']['formatted_date'] == $dates['value2']['formatted_date']) {
// Replace the original time with the from/to time in the formatted start date.
// Make sure that parentheses or brackets wrapping the time will be retained in the
// final result.
$time1 = preg_replace('`^([\\(\\[])`', '', $dates['value']['formatted_time']);
$time1 = preg_replace('([\\)\\]]$)', '', $time1);
$time2 = preg_replace('`^([\\(\\[])`', '', $dates['value2']['formatted_time']);
$time2 = preg_replace('([\\)\\]]$)', '', $time2);
$time = theme('date_display_range', $time1, $time2);
$replaced = str_replace($time1, $time, $date1);
$output .= theme('date_display_single', $replaced, $timezone);
}
else {
$output .= theme('date_display_range', $date1, $date2, $timezone);
}
return $output;
}