hi
I have a ISO_DATE field in a custom table and i want to use the filtering/arguments that date_views provide
but it seem not working
problem is views creates sql based on unix timestamp
what i implemented so far:
hook_views_data:
$data['temperatures']['datetime'] = array(
'title' => t('Datetime'),
'help' => t('Datetime.'),
'field' => array(
'handler' => 'date_handler_field_date',
'click sortable' => TRUE,
'is date' => TRUE,
),
'filter' => array(
'handler' => 'date_views_filter_handler',
'is date' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort_date',
'is date' => TRUE,
),
);
hook_date_views_fields:
$values = array(
// The type of date: DATE_UNIX, DATE_ISO, DATE_DATETIME.
'sql_type' => DATE_ISO,
// Timezone handling options: 'none', 'site', 'date', 'utc' .
'tz_handling' => 'none',
// Needed only for dates that use 'date' tz_handling.
'timezone_field' => '',
// Needed only for dates that use 'date' tz_handling.
'offset_field' => '',
// Array of "table.field" values for related fields that should be
// loaded automatically in the Views SQL.
'related_fields' => array(),
// Granularity of this date field's db data.
'granularity' => array('year', 'month', 'day', 'hour', 'minute', 'second'),
);
switch ($field) {
case 'temperature.datetime':
return $values;
}
but in date_views_fields.inc line:145 replaces the sql_type by it's default value: DATE_UNIX
Comments
Comment #1
dalinI was running into this issue as well, and this ticket helped me to figure out the solution.
In mymodule.views.inc:
And in mymodule.module: