1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_field_time_interval.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* A handler to provide proper displays for time intervals.
|
10
|
*
|
11
|
* @ingroup views_field_handlers
|
12
|
*/
|
13
|
class views_handler_field_time_interval extends views_handler_field {
|
14
|
function option_definition() {
|
15
|
$options = parent::option_definition();
|
16
|
|
17
|
$options['granularity'] = array('default' => 2);
|
18
|
|
19
|
return $options;
|
20
|
}
|
21
|
|
22
|
function options_form(&$form, &$form_state) {
|
23
|
parent::options_form($form, $form_state);
|
24
|
|
25
|
$form['granularity'] = array(
|
26
|
'#type' => 'textfield',
|
27
|
'#title' => t('Granularity'),
|
28
|
'#description' => t('How many different units to display in the string.'),
|
29
|
'#default_value' => $this->options['granularity'],
|
30
|
);
|
31
|
}
|
32
|
|
33
|
function render($values) {
|
34
|
$value = $values->{$this->field_alias};
|
35
|
return format_interval($value, isset($this->options['granularity']) ? $this->options['granularity'] : 2);
|
36
|
}
|
37
|
}
|