You are here

function theme_commons_events_date_display_range_simple in Drupal Commons 7.3

Returns specific HTML for a date element formatted with the event formatter M j Y - g:ia.

We the do some awesome stuff with regular expressions to take all the different formats available to us and format it pretty.

1 theme call to theme_commons_events_date_display_range_simple()
theme_commons_events_date_display_range_advanced in modules/commons/commons_events/commons_events.module
Returns specific HTML for a date element formatted with the event formatter.

File

modules/commons/commons_events/commons_events.module, line 531

Code

function theme_commons_events_date_display_range_simple($variables) {

  // Use the regular date formatter if we are any other date format than below.
  $date1 = $variables['dates']['value']['formatted_date'];
  $date2 = $variables['dates']['value2']['formatted_date'];
  $time1 = $variables['dates']['value']['formatted_time'];
  $time2 = $variables['dates']['value2']['formatted_time'];
  $timezone = $variables['timezone'];
  $attributes_start = $variables['attributes_start'];
  $attributes_end = $variables['attributes_end'];
  if ($date1 == $date2) {

    // Wrap the result with the attributes.
    return t('!start-time - !end-time', array(
      '!start-time' => '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $time1 . '</span>',
      '!end-time' => '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $time2 . $timezone . '</span>',
    ));
  }

  // Wrap the result with the attributes.
  return t('!start-date to !end-date, !start-time - !end-time', array(
    '!start-date' => '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $date1 . '</span>',
    '!end-date' => '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $date2 . '</span>',
    '!start-time' => '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $time1 . '</span>',
    '!end-time' => '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $time2 . $timezone . '</span>',
  ));
}