partial_date.inc in Views TimelineJS integration 7
File
views_timelinejs_extra_sources/plugins/date_sources/partial_date.inc
View source
<?php
$plugin = array(
'name' => t('Partial Date field for TimelineJS'),
'callback' => 'views_timelinejs_date_source_date_partial_field_conversion',
'handler_name' => 'views_handler_field_field',
'field_type' => 'partial_date',
);
function views_timelinejs_date_source_date_partial_field_conversion($date, $output_format, $options = array()) {
switch ($output_format) {
case 'csv':
$ret['value'] = $date['from']['year'] . ', ' . $date['from']['month'] . ', ' . $date['from']['day'];
if (isset($date['to']['year'])) {
$ret['value2'] = $date['to']['year'] . ', ' . $date['to']['month'] . ', ' . $date['to']['day'];
}
break;
case 'timestamp':
$ret['value'] = $date['timestamp'];
break;
}
if (isset($ret['value2']) && $ret['value'] == $ret['value2']) {
unset($ret['value2']);
}
return $ret;
}