You are here

function ws_datefield_wsfields_datetime_data_alter in Web Service Data 7

Implements hook_wsfields_FIELD_TYPE_data_alter().

Prepares data for the 'date' field type

File

modules/ws_datefield/ws_datefield.module, line 82
Main module for ws_datefields

Code

function ws_datefield_wsfields_datetime_data_alter($data, $field) {

  // Build the field array as required
  if (!is_array($data)) {
    $field_data = _ws_datefield_map_datetime($data, $field);
  }
  else {
    if (isset($field['storage']['settings']['translation']) and $field['storage']['settings']['translation']) {
      foreach ($data as $language => $values) {
        foreach ($values as $value) {
          $field_data = _ws_datefield_map_datetime($value, $field);
        }
      }
    }
    else {
      foreach ($data as $value) {
        $field_data = _ws_datefield_map_datetime($value, $field);
      }
    }
  }

  // Save the new field data
  return $field_data;
}