You are here

function date_columns in Date 6

Same name and namespace in other branches
  1. 5.2 date/date_admin.inc \date_columns()
  2. 5 date_admin.inc \date_columns()
  3. 6.2 date/date_admin.inc \date_columns()

Callback for field columns.

1 call to date_columns()
_date_field_settings in date/date_admin.inc
Implementation of hook_field_settings().

File

date/date_admin.inc, line 307
Date administration code. Moved to separate file since there is a lot of code here that is not needed often.

Code

function date_columns($field) {
  if ($field['type'] == 'date') {
    $db_columns['value'] = array(
      'type' => 'varchar',
      'length' => 20,
      'not null' => FALSE,
      'sortable' => TRUE,
    );
  }
  elseif ($field['type'] == 'datestamp') {
    $db_columns['value'] = array(
      'type' => 'int',
      'length' => 11,
      'not null' => FALSE,
      'sortable' => TRUE,
    );
  }
  elseif ($field['type'] == 'datetime') {
    $db_columns['value'] = array(
      'type' => 'datetime',
      'not null' => FALSE,
      'sortable' => TRUE,
    );
  }

  // If a second date is needed for 'To date', just make a copy of the first one.
  if (isset($field['todate'])) {
    $db_columns['value2'] = $db_columns['value'];
  }

  // timezone and offset columns are used only if date-specific dates are chosen.
  if (isset($field['tz_handling']) && $field['tz_handling'] == 'date') {
    $db_columns['timezone'] = array(
      'type' => 'varchar',
      'length' => 50,
      'not null' => FALSE,
      'sortable' => TRUE,
    );
    $db_columns['offset'] = array(
      'type' => 'int',
      'length' => 10,
      'not null' => FALSE,
      'sortable' => TRUE,
    );
    if ($field['todate']) {
      $db_columns['offset2'] = array(
        'type' => 'int',
        'length' => 10,
        'not null' => FALSE,
        'sortable' => TRUE,
      );
    }
  }
  if (isset($field['repeat']) && $field['repeat'] == 1) {
    $db_columns['rrule'] = array(
      'type' => 'text',
      'not null' => FALSE,
      'sortable' => FALSE,
    );
  }
  return $db_columns;
}