You are here

protected function views_timelinejs_plugin_style_timelinejs::build_date in Views TimelineJS integration 7.3

Builds a timeline date from the current data row.

Parameters

string $field: The machine name of the date field.

Return value

TimelineDate|NULL A date object or NULL if the start date could not be parsed.

2 calls to views_timelinejs_plugin_style_timelinejs::build_date()
views_timelinejs_plugin_style_timelinejs::build_era in ./views_timelinejs_plugin_style_timelinejs.inc
Builds a timeline era from the current views data row.
views_timelinejs_plugin_style_timelinejs::build_slide in ./views_timelinejs_plugin_style_timelinejs.inc
Builds a timeline slide from the current views data row.

File

./views_timelinejs_plugin_style_timelinejs.inc, line 469

Class

views_timelinejs_plugin_style_timelinejs
Style plugin to render items as TimelineJS3 slides.

Code

protected function build_date($field) {
  try {

    // Strip HTML tags from dates so users don't run into problems like Date
    // fields wrapping their output with metadata.
    $date_string = strip_tags($this
      ->get_field($this->view->row_index, $field));
    $date = new TimelineDate($date_string);
  } catch (Exception $e) {

    // Return NULL if the field didn't contain a parseable date string.
    views_debug('The date "@date" does not conform to a <a href="@php-manual">PHP supported date and time format</a>.', array(
      '@date' => $date_string,
      '@php-manual' => 'http://php.net/manual/en/datetime.formats.php',
    ));
    return NULL;
  }
  return $date;
}