You are here

function _eloqua_form_url_map_date in Eloqua 6

Convert URLDate to form date The date must be in yyyy-mm-dd format

Parameters

$value:

$element:

Return value

void

File

./eloqua.module, line 508

Code

function _eloqua_form_url_map_date($value, &$element) {
  $split = explode('-', $value);

  // Valdiate format
  if (count($split) != 3 || !is_numeric($split[0]) || !is_numeric($split[1]) || !is_numeric($split[2])) {
    return;
  }
  $year = (int) $split[0];
  $month = (int) $split[1];
  $day = (int) $split[2];

  // Valdiate value
  if ($year < 0 || $year > 9999 || !checkdate($month, $day, $year)) {
    return;
  }

  // Update the default value.
  // THe webform #process function expects a keyed array.
  $element['#default_value'] = array(
    'year' => $year,
    'month' => $month,
    'day' => $day,
  );
}