function theme_date_all_day in Date 7.2
Same name and namespace in other branches
- 8 date_all_day/date_all_day.module \theme_date_all_day()
- 5.2 date/date.theme \theme_date_all_day()
- 6.2 date/date.theme \theme_date_all_day()
- 7.3 date_all_day/date_all_day.module \theme_date_all_day()
- 7 date.theme \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',
));
}
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 = date_limit_format($format, array(
'year',
'month',
'day',
));
$suffix = ' ' . theme('date_all_day_label');
}
}
return trim(date_format_date(${$which}, 'custom', $format) . $suffix);
}