Ajax callback; Returns the date for a given format string.
function system_date_time_lookup($form, &$form_state) {
  $format = '';
  if (!empty($form_state['values']['date_format_pattern'])) {
    $format = t('Displayed as %date_format', array(
      '%date_format' => format_date(REQUEST_TIME, 'custom', $form_state['values']['date_format_pattern']),
    ));
  }
  // Return a command instead of a string, since the Ajax framework
  // automatically prepends an additional empty DIV element for a string, which
  // breaks the layout.
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand('#edit-date-format-suffix', '<small id="edit-date-format-suffix">' . $format . '</small>'));
  return $response;
}