You are here

function date_default_value in Date 5

Same name and namespace in other branches
  1. 8 date.module \date_default_value()
  2. 7.3 date_elements.inc \date_default_value()
  3. 7.2 date_elements.inc \date_default_value()

Set the date default values.

@todo expand on this in the future

1 call to date_default_value()
date_widget in ./date.module
Implementation of hook_widget().

File

./date.module, line 356
Defines a date/time field type.

Code

function date_default_value($node, $field, $items, $delta) {
  include_once drupal_get_path('module', 'date_api') . '/date.inc';
  if ($field['required']) {
    $default_date = $field['type'] == 'datestamp' ? time() : date_unix2iso(time());
  }
  else {
    $default_date = NULL;
  }
  if ($field['todate'] == 'required') {
    return array(
      0 => array(
        'value' => $default_date,
        'value2' => $default_date,
      ),
    );
  }
  elseif ($field['todate'] == 'optional') {
    return array(
      0 => array(
        'value' => $default_date,
        'value2' => NULL,
      ),
    );
  }
  else {
    return array(
      0 => array(
        'value' => $default_date,
      ),
    );
  }
}