You are here

function _date_field_update in Date 6.2

Same name and namespace in other branches
  1. 5.2 date/date_elements.inc \_date_field_update()
  2. 6 date/date_elements.inc \_date_field_update()

Private implementation of hook_field update and insert operations.

1 call to _date_field_update()
date_field in date/date.module
Implementation of hook_field().

File

date/date_elements.inc, line 43
Date forms and form themes and validation.

Code

function _date_field_update($op, &$node, $field, &$items, $teaser, $page) {
  $field_name = $field['field_name'];
  if (empty($items)) {

    //$node->$field_name = array(); // Not sure about this, CCK should handle it.
    return;
  }
  $values = $items;
  foreach ($values as $delta => $item) {

    // Special case for ISO dates which may have been given artificial values for
    // some date parts to make them into valid dates.
    if (!empty($item['value']) && $field['type'] == DATE_ISO) {
      $items[$delta]['value'] = date_limit_value($items[$delta]['value'], date_granularity($field), $field['type']);
      if ($field['todate']) {
        $items[$delta]['value2'] = date_limit_value($items[$delta]['value2'], date_granularity($field), $field['type']);
      }
    }
  }
  $node->{$field}['field_name'] = $items;
}